Prev: TIPs 366 and 368
Next: different buttons
From: Stuart on 18 May 2010 19:17 Greeting.. I'm trying to create a script thet generates a scrollable widget consisting of several canvases stacked on top of one another. I can't seem to get the scrollbar working properly; when I move the scrollbar the stacked canvases don't move in the viewing area. So clearly I haven't coupled the scrollbar to the widget properly. I start out creating a simple canvas, and then using windows I embed framed canvas widgets within that canvas. Perhaps what I'm doing can't really be done in TK? The reason I'm embedding canvases within a canvas, is that it will save me a whole lot of book keeping for what I need to do. Any suggestions welcome. Stuart Here is my script #!/usr/bin/wish frame .gui -background black canvas .gui.can set y_coor 0 set ydim 100 ..gui.can configure -yscrollcommand [list .gui.scroll set] -relief flat -borderwidth 5 -background black -height 500 -width 600\ -scrollregion [list 0 0 0 1000] scrollbar .gui.scroll -command [list .gui.can yview] -relief raised foreach sta {sta1 sta2 sta3 sta4 sta5 sta6 sta7 sta8 sta9 sta10} { puts $sta frame .gui.can.fr$sta -relief groove -borderwidth 5 - width 600 -height 100 -background bisque set id [.gui.can create window 1 $y_coor -anchor w - window .gui.can.fr$sta -width 600 -height 100] label .gui.can.fr$sta.lbl -text "$sta" -fg darkviolet canvas .gui.can.fr$sta.can -width 600 -height 100 -bg bisque # # Increment variables # set y_coor [expr {$y_coor + $ydim}] puts $y_coor pack .gui.can.fr$sta.lbl .gui.can.fr$sta.can -side left pack .gui.can.fr$sta } pack .gui.can .gui.scroll -side left -fill both pack .gui -expand true -fill both wm title . "TEST" wm geometry . 670x500+200+200
From: MSEdit on 19 May 2010 06:33 On May 19, 1:17 am, Stuart <bigdak...(a)aol.com> wrote: > Greeting.. > > I'm trying to create a script thet generates a scrollable widget > consisting of several > canvases stacked on top of one another. I can't seem to get the > scrollbar working > properly; when I move the scrollbar the stacked canvases don't move in > the viewing area. > So clearly I haven't coupled the scrollbar to the widget properly. > > I start out creating a simple canvas, and then using windows I embed > framed canvas widgets > within that canvas. Perhaps what I'm doing can't really be done in TK? > > The reason I'm embedding canvases within a canvas, is that it will > save me a whole > lot of book keeping for what I need to do. > > Any suggestions welcome. > > Stuart > > Here is my script > #!/usr/bin/wish > > frame .gui -background black > canvas .gui.can > > set y_coor 0 > set ydim 100 > .gui.can configure -yscrollcommand [list .gui.scroll set] -relief > flat -borderwidth 5 -background black -height 500 -width 600\ > -scrollregion [list 0 0 0 1000] > scrollbar .gui.scroll -command [list .gui.can yview] -relief raised > > foreach sta {sta1 sta2 sta3 sta4 sta5 sta6 sta7 sta8 sta9 sta10} { > > puts $sta > > frame .gui.can.fr$sta -relief groove -borderwidth 5 - > width 600 -height 100 -background bisque > set id [.gui.can create window 1 $y_coor -anchor w - > window .gui.can.fr$sta -width 600 -height 100] > label .gui.can.fr$sta.lbl -text "$sta" -fg darkviolet > canvas .gui.can.fr$sta.can -width 600 -height 100 -bg > bisque > # > # Increment variables > # > set y_coor [expr {$y_coor + $ydim}] > puts $y_coor > pack .gui.can.fr$sta.lbl .gui.can.fr$sta.can -side left > pack .gui.can.fr$sta > > } > pack .gui.can .gui.scroll -side left -fill both > pack .gui -expand true -fill both > wm title . "TEST" > wm geometry . 670x500+200+200 BWidget has a scrollable frame thingy where you can pack several different widgets into a scrolling frame with one scrollbar. Look at the demo.tcl its on the first page bottom right hand. Martyn
From: Stuart on 19 May 2010 23:22 On May 19, 12:33 am, MSEdit <mse...(a)gmail.com> wrote: > On May 19, 1:17 am, Stuart <bigdak...(a)aol.com> wrote: > > > > > Greeting.. > > > I'm trying to create a script thet generates a scrollable widget > > consisting of several > > canvases stacked on top of one another. I can't seem to get the > > scrollbar working > > properly; when I move the scrollbar the stacked canvases don't move in > > the viewing area. > > So clearly I haven't coupled the scrollbar to the widget properly. > > > I start out creating a simple canvas, and then using windows I embed > > framed canvas widgets > > within that canvas. Perhaps what I'm doing can't really be done in TK? > > > The reason I'm embedding canvases within a canvas, is that it will > > save me a whole > > lot of book keeping for what I need to do. > > > Any suggestions welcome. > > > Stuart > > > Here is my script > > #!/usr/bin/wish > > > frame .gui -background black > > canvas .gui.can > > > set y_coor 0 > > set ydim 100 > > .gui.can configure -yscrollcommand [list .gui.scroll set] -relief > > flat -borderwidth 5 -background black -height 500 -width 600\ > > -scrollregion [list 0 0 0 1000] > > scrollbar .gui.scroll -command [list .gui.can yview] -relief raised > > > foreach sta {sta1 sta2 sta3 sta4 sta5 sta6 sta7 sta8 sta9 sta10} { > > > puts $sta > > > frame .gui.can.fr$sta -relief groove -borderwidth 5 - > > width 600 -height 100 -background bisque > > set id [.gui.can create window 1 $y_coor -anchor w - > > window .gui.can.fr$sta -width 600 -height 100] > > label .gui.can.fr$sta.lbl -text "$sta" -fg darkviolet > > canvas .gui.can.fr$sta.can -width 600 -height 100 -bg > > bisque > > # > > # Increment variables > > # > > set y_coor [expr {$y_coor + $ydim}] > > puts $y_coor > > pack .gui.can.fr$sta.lbl .gui.can.fr$sta.can -side left > > pack .gui.can.fr$sta > > > } > > pack .gui.can .gui.scroll -side left -fill both > > pack .gui -expand true -fill both > > wm title . "TEST" > > wm geometry . 670x500+200+200 > > BWidget has a scrollable frame thingy where you can pack several > different widgets into a scrolling frame with one scrollbar. > > Look at the demo.tcl its on the first page bottom right hand. > > Martyn Thanks Martyn... I modified a script.. to show a scrollable window that contains canvases.. Only a couple of questions.. I'd like to make the bottom most canvases visible instead of the top which appears to be the default behavior. But if I uncomment the $sf see... command I get an error because winfo claims the widget .sw.sf.frame.sta1 doesn't exist, although it certainly exists in name. So I'm not sure how to properly use the "see" option to accomplish what I want. Maybe I can't use "see"? dunno. The other thing I'd like, is to be able to show the entire horizontal extent so that the horizontal scrollbar isn't needed. Thanks, Stuart #!/usr/bin/wish package require BWidget font create name_font -size 10 -weight bold -family Courier set width [font measure name_font "AAAAA"] puts $width # Make a frame scrollable set sw [ScrolledWindow .sw -ipad 0] puts $sw pack $sw -fill both -expand true set sf [ScrollableFrame $sw.sf ] $sw setwidget $sf set path [$sf getframe] puts "path $path" # Now fill the frame, resize the window to see the scrollbars in action foreach sta {sta1 sta2 sta3 sta4 sta5 sta6 sta7 sta8 sta9 sta10} { set sta [format "%-5.5s" $sta] set fr [format "%s.%s" $path $sta ] set nml [format "%s.%s.lbl" $path $sta ] set nmc [format "%s.%s.can" $path $sta ] set frame [frame $fr -borderwidth 2 -bg black ] puts $frame canvas $nmc -bg bisque -width 600 -height 51 -borderwidth 0 label $nml -text $sta -fg darkviolet -bg bisque -borderwidth 0 -font name_font pack $nml $nmc -side left -fill both -expand true pack $fr -side bottom } puts [winfo exists .sw.sf.frame.sta1] puts [winfo exists $path.sta1] #$sf see $path.sta1 puts $path.sta1
|
Pages: 1 Prev: TIPs 366 and 368 Next: different buttons |