Re: scrollbar question



You don't grid the frame into the text widget.

Read the man/help page for text widget, pay particular attention to the window subcommand.

BTW, you may also want to check out ScrolledWindow megawidget from the BWidgets package.

madman wrote:
I'm a self-proclaimed "intermediate" level tcl programmer and I'm
having problems displaying data in a scrolling window. Basically, I
want to display some data (rows and columns) in a window that can be
scrolled. My idea was to insert a grid frame inside a textbox with a
scrollbar attached. My problem is that although the scrollbar appears,
it doesn't "scroll". Can anybody help me?? Below is a sample code:

toplevel .manBox
wm geometry .manBox +300+5

scrollbar .manBox.scroll -command ".manBox.view yview"
text .manBox.view -yscrollcommand ".manBox.scroll set"
frame .manBox.view.grid

set c1_result 1.0
set c2_result 2.0
set c3_result 3.0

set c1 [label .manBox.view.grid.c1_0 -text "Port #"]
set c2 [label .manBox.view.grid.c2_0 -text "Diff #"]
set c3 [label .manBox.view.grid.c3_0 -text "Port E"]

grid $c1 -row 0 -column 1
grid $c2 -row 0 -column 2
grid $c3 -row 0 -column 3

for {set i 1} {$i <= 25} {incr i} {

set c1 [label .manBox.view.grid.c1_$i -textvariable c1_result]
set c2 [label .manBox.view.grid.c2_$i -textvariable c2_result]
set c3 [label .manBox.view.grid.c3_$i -textvariable c3_result]

grid $c1 -row $i -column 1
grid $c2 -row $i -column 2
grid $c3 -row $i -column 3
}

pack .manBox.scroll -side right -fill y
pack .manBox.view
grid .manBox.view.grid -in .manBox.view
.manBox.view configure -state disable



--
+--------------------------------+---------------------------------------+
| Gerald W. Lester |
|"The man who fights for his ideals is the man who is alive." - Cervantes|
+------------------------------------------------------------------------+
.



Relevant Pages

  • Re: changing looks in a main window
    ... window, seems to overboard. ... MainWindow) and call pack() and packForgeton that frame. ... hrmm, ok, so should i use pack then instead of grid? ...
    (comp.lang.perl.tk)
  • Re: How to scrollbar to existing window
    ... Now I want to add yscollbar to a particular window. ... canvas $curWin.canvas -highlightthickness 0 ... You want to grid the scrollbar someplace, ... This puts the scrollbar on the right. ...
    (comp.lang.tcl)
  • Re: Packing problems
    ... but the frame there are in is centered horizontally. ... pack your text widget absolutely last and you'll get better resize behavior. ... Many windows applications put both the scrollbar and text widget inside a common frame that is sunken. ... commands and then resize the window to be smaller, you'll see the effect I describe in the tclscripting.com article where the scrollbars disappear before the text widget shrinks. ...
    (comp.lang.tcl)
  • Re: changing looks in a main window
    ... window, seems to overboard. ... MainWindow) and call pack() and packForgeton that frame. ... hrmm, ok, so should i use pack then instead of grid? ...
    (comp.lang.perl.tk)
  • geometry propagation
    ... window is manipulated. ... then the grid is centered inside the ... "create_mockframe" sticks widgets into a frame ...
    (comp.lang.tcl)