Message-ID: <42A3F4A5.3060900@freenet.de>
I recently found this very useful widget TkScrollbar. It works great, if
you need a listbox with vertical scrollbar.
What I am missing is some more documentation. What, if i need a
horizontal bar or in my case both?
Here you are. Please see "<ruby-src>/ext/tk/sample/tktextframe.rb" also.
ยทยทยท
From: Enrico Schwass <deckard73@freenet.de>
Subject: TkScrollbox with horizontal scrollbar
Date: Mon, 6 Jun 2005 15:59:06 +0900
----------------------------------------------------
#
require 'tk'
class TkXYScrollbox<TkListbox
include TkComposite
def initialize_composite(keys=nil)
list = TkListbox.new(@frame)
xscr = TkScrollbar.new(@frame)
yscr = TkScrollbar.new(@frame)
@path = list.path
list.xscrollbar(xscr)
list.yscrollbar(yscr)
TkGrid.rowconfigure(@frame, 0, 'weight'=>1, 'minsize'=>0)
TkGrid.columnconfigure(@frame, 0, 'weight'=>1, 'minsize'=>0)
list.grid('row'=>0, 'column'=>0, 'sticky'=>'news')
xscr.grid('row'=>1, 'column'=>0, 'sticky'=>'ew')
yscr.grid('row'=>0, 'column'=>1, 'sticky'=>'ns')
delegate('DEFAULT', list)
delegate('foreground', list)
delegate('background', list, xscr, yscr)
delegate('borderwidth', @frame)
delegate('relief', @frame)
configure keys if keys
end
private :initialize_composite
end
################################################
# test
################################################
if __FILE__ == $0
lst = TkXYScrollbox.new(:height=>7).pack
('A'..'Z').each_with_index{|s, n| lst.insert(:end, s*(n+1))}
Tk.mainloop
end
----------------------------------------------------
Of course, you can use a TkScrollbox with a horizontal scrollbar.
However, probably you'll have some trouble on layouting them.
It is better to define a new class which use grid geometry manager
instead of pack geometry manager.
--
Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)