Hi!  I'm running VTCL v1.07 and have a query regarding the lifespan of 
     widgets and what happens when you save the project.  I have a number 
     of buttons on a form and when you right-click each one, it calls a 
     generic function which displays a popup menu.  The code which binds 
     the rightclick to button 1, for example, is:
        
         bind .top1.butt1 <Button-3> {
             PopUp %W %X %Y 1
         }
     
     PopUp is defined as:
     
          proc PopUp {Wid XCoor YCoor Num} {
                menu $Wid.popup
                $Wid.popup add command -label "First" -command DoFirst
                $Wid.popup add command -label "Last" -command DoLast
                tk_popup $Wid.popup $XCoord $YCoord
          }
     
     This works fine in test mode popping up the little menu.  However, 
     when I save the project and vi the source file, I notice that the code 
     that vTcl has generated for this button now includes the definition 
     for the widget created by the PopUp menu.  ie:
     
        bind .top1.butt1 <Button-3> {
                PopUp %W %X %Y 1
        }
        menu .top1.butt1.popup
        .top1.butt1.popup add  command -label "First" -command DoFirst
        .top1.butt1.popup add  command -label "Last"  -command DoLast
     
     What I'm trying to point out is that when I switch to test mode and 
     click to popup this little menu, a widget is created on the fly and 
     this is now included in the source code when the project is saved!
     
     I guess that I should be doing a destroy of the popup widget when it 
     closes, but what if the script crashes in test mode and leaves the 
     widget created, as this will cause the widget to be included in the 
     next save.  
     
     What I want to do is call the generic PopUp function for each button, 
     but I don't want it to leave behind an instance of that button.  
     
     Is anyone following this and if so any suggestions would be most 
     appreciated as I am concerned that whilst developing my software, the 
     source is going to fill up with widgets.  It's almost as if vTcl can't 
     keep track of which widgets are in the source code, and which are 
     generated on the fly and then including both in the source code.  One 
     way I can think of working round this is to develop and design using 
     vTcl, but test the code in another window using wish.  Or am I doing 
     something completely wrong here?  BTW I am fairly new to tcl/tk so 
     please don't shout if I am :)
     
     Regards,
     
     -Richard
       
     
     
     
     
     

Reply via email to