I’m having trouble getting grid to show me something.
I am trying to write a routine (called from within initialize) that will
fill a TkPanel with a TkText or TkListbox, all linked up with two
scrollbars.
Def widgetIn(parent,type)
# return a widet of type within parent, all linked up with two
scroll bars
# and laid out with grid
widget = type.new(parent)
xscroll = TkScrollbar.new(parent,
‘orient’=>‘horizontal’,
‘command’=> proc{|*args| widget.xview
*args })
yscroll = TkScrollbar.new(parent,
‘orient’=>‘vertical’,
‘command’=> proc{|*args| widget.yview
*args })
widget.yscrollcommand(proc {|first,last| yscroll.set(first, last)})
widget.xscrollcommand(proc {|first,last| xscroll.set(first, last)})
here is where I am stuck.
now I need to grid them with ‘sticky’=>‘news’ in layout
grid(widget, yscroll)
grid(xscroll)
and then (possibly) call gridColumnconfigure(1,‘weight’=>1)
and gridRowConfigure(1,'weight=>1) to set the grid to
the right shape.
Everything I have tried has failed. What is the correct form? I’m trying
to translate from TCL and perl but I know neither language!!
Thanks
Ian
···
–
Ian - posting to a Newsgroup. Please remove everything to reply.
where griddedPanel is the parent being managed by grid.
And finally. I had to pack a parent before I saw anything at
all!
The routine is now.
def widgetIn(parent,type)
# return a widget of type within parent,
# all linked up with two scroll bars
# and laid out with grid
# type may be TkListbox or TkText (TkCanvas not tested)
widget = type.new(parent)
widget.grid(‘row’=>0, ‘column’=>0, ‘sticky’=>‘news’)
yscroll = TkScrollbar.new(parent,
‘orient’=>‘vertical’,
‘command’=> proc{|*args| widget.yview
*args })
yscroll.grid(‘row’=>0, ‘column’=>1, ‘sticky’=>‘ns’)
xscroll = TkScrollbar.new(parent,
‘orient’=>‘horizontal’,
‘command’=> proc{|*args| widget.xview
*args })
xscroll.grid(‘row’=>1, ‘column’=>0, ‘sticky’=>‘ew’)
widget.yscrollcommand(proc {|first,last| yscroll.set(first,
last)})
widget.xscrollcommand(proc {|first,last| xscroll.set(first,
last)})
TkGrid.rowconfigure(parent,0,‘weight’=>1)
TkGrid.columnconfigure(parent,0,‘weight’=>1)
widget
end
I also needed to know that the rowconfigure command is
TkGrid.rowconfigure(griddedPanel, rowNo , “weight”=>1)
and
TkGrid.columconfigure(griddedPanel, rowNo, “weight”=>1)
where griddedPanel is the parent being managed by grid.
Or, griddedPanel.grid_rowconfig(rowNo , “weight”=>1)
and griddedPanel.grid_columnconfig(rowNo , “weight”=>1).