Tk Help needed with grid

Hi All,

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.

I’m having trouble getting grid to show me something.

Does the last example on this page help?

http://httpd.chello.nl/k.vangelder/ruby/learntk/scrollbars.html

(I admit I haven’t checked in detail what you want)

hth,
Kero.

±-- Kero ----------------------- kero@chello.nl —+

all the meaningless and empty words I spoke |
Promises – The Cranberries |
±-- M38c — http://httpd.chello.nl/k.vangelder —+

Yes it did thanks.

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.

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

and it works.

Regards

Ian

···

In message pan.2003.12.06.09.08.43.479864@chello.single-dot.nl, Kero kero@chello.single-dot.nl writes

I’m having trouble getting grid to show me something.

Does the last example on this page help?

http://httpd.chello.nl/k.vangelder/ruby/learntk/scrollbars.html


Ian - posting to a Newsgroup. Please remove everything to reply.

Hi,

···

From: Ian Hobson NewGroups@ntlworld.everything.com
Subject: Re: Tk Help needed with grid
Date: Sat, 6 Dec 2003 20:07:07 +0900
Message-ID: gMDVmmBxdb0$Ewwm@ntlworld.com

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).

                              Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)