M
matt
Given the following code:
-------------------------------------
require 'ext/tkscrollinglistbox'
root = TkRoot.new
text = TkEntry.new(root, 'width'=>100)
list = TkScrollingListbox.new(root, 'width'=>50, 'label'=>'Meow')
list.instance_eval { @frame.configure('background'=>'blue') }
root.configure('background'=>'yellow')
text.pack('side'=>'top', 'fill'=>'x', 'expand'=>true)
list.pack('side'=>'top', 'fill'=>'both', 'expand'=>true)
Tk.mainloop
-------------------------------------
and ext/tkscrollinglistbox being (method_configure basically calls a
method with a given value when used in TkComposite.configure - the
version in CVS has something like this, I just haven't updated....)
-------------------------------------
require 'tk'
class TkScrollingListbox < TkWindow
include TkComposite
def initialize_composite(keys={})
keys = _symbolkey2str(keys)
@label = TkLabel.new(@frame)
@list = TkListbox.new(@frame)
@x = TkScrollbar.new(@frame)
@y = TkScrollbar.new(@frame)
delegate('DEFAULT', @list)
@path = @list.path
method_configurescrollbars, :label, :labelspot)
@list.yscrollbar(@y)
@list.xscrollbar(@x)
@list.grid('row'=>1, 'column'=>0, 'sticky'=>'nsew')
listbox_event = Proc.new {|e| $stderr.puts "HERE!";
self.event_generate(e)}
@list.bind('<ListboxSelect>') { listbox_event['<ListboxSelect>'] }
self.bind('<ListboxSelect>') {}
@lblWhere = 'top'
@lblPlaced = false
configure keys unless keys.empty?
end
def scrollbars(scroll)
case scroll.to_s.downcase
when 'both' then @x.grid('row'=>2, 'column'=>0, 'sticky'=>'ew')
@y.grid('row'=>1, 'column'=>1, 'sticky'=>'ns')
when 'x' then @x.grid('row'=>2, 'column'=>0, 'sticky'=>'ew')
@y.ungrid
when 'y' then @y.grid('row'=>1, 'column'=>1, 'sticky'=>'ns')
@x.ungrid
when 'none' then @x.ungrid
@y.ungrid
end
end
def label(text)
if text.nil? then
@lblPlaced = false
@label.ungrid
else
@label.text text
@lblPlaced = true
@label.grid('row'=>(@lblWhere == 'top' ? 0 : 3), 'column'=>0,
'columnspan'=>2)
end
end
def labelspot(value)
unless value.nil? then
@lblWhere = value
label(@label.text) if @lblPlaced
end
@lblWhere
end
def method_missing(sym, *args)
if @list.respond_to?(sym) then
@list.send(sym, *args)
else
super(sym, *args)
end
end
alias old_respond_to respond_to?
def respond_to?(sym)
return true if old_respond_to(sym)
return true if @list.respond_to?(sym)
return false
end
end
-------------------------------------
My question is why doesn't the listbox in the TkScrollingListbox
expand and fill the frame when the frame gets more space -- I made it
sticky(news)... do I have a misunderstanding of the grid layout
manager? Is the world completely topsy turvy? Please help! Thanks
-------------------------------------
require 'ext/tkscrollinglistbox'
root = TkRoot.new
text = TkEntry.new(root, 'width'=>100)
list = TkScrollingListbox.new(root, 'width'=>50, 'label'=>'Meow')
list.instance_eval { @frame.configure('background'=>'blue') }
root.configure('background'=>'yellow')
text.pack('side'=>'top', 'fill'=>'x', 'expand'=>true)
list.pack('side'=>'top', 'fill'=>'both', 'expand'=>true)
Tk.mainloop
-------------------------------------
and ext/tkscrollinglistbox being (method_configure basically calls a
method with a given value when used in TkComposite.configure - the
version in CVS has something like this, I just haven't updated....)
-------------------------------------
require 'tk'
class TkScrollingListbox < TkWindow
include TkComposite
def initialize_composite(keys={})
keys = _symbolkey2str(keys)
@label = TkLabel.new(@frame)
@list = TkListbox.new(@frame)
@x = TkScrollbar.new(@frame)
@y = TkScrollbar.new(@frame)
delegate('DEFAULT', @list)
@path = @list.path
method_configurescrollbars, :label, :labelspot)
@list.yscrollbar(@y)
@list.xscrollbar(@x)
@list.grid('row'=>1, 'column'=>0, 'sticky'=>'nsew')
listbox_event = Proc.new {|e| $stderr.puts "HERE!";
self.event_generate(e)}
@list.bind('<ListboxSelect>') { listbox_event['<ListboxSelect>'] }
self.bind('<ListboxSelect>') {}
@lblWhere = 'top'
@lblPlaced = false
configure keys unless keys.empty?
end
def scrollbars(scroll)
case scroll.to_s.downcase
when 'both' then @x.grid('row'=>2, 'column'=>0, 'sticky'=>'ew')
@y.grid('row'=>1, 'column'=>1, 'sticky'=>'ns')
when 'x' then @x.grid('row'=>2, 'column'=>0, 'sticky'=>'ew')
@y.ungrid
when 'y' then @y.grid('row'=>1, 'column'=>1, 'sticky'=>'ns')
@x.ungrid
when 'none' then @x.ungrid
@y.ungrid
end
end
def label(text)
if text.nil? then
@lblPlaced = false
@label.ungrid
else
@label.text text
@lblPlaced = true
@label.grid('row'=>(@lblWhere == 'top' ? 0 : 3), 'column'=>0,
'columnspan'=>2)
end
end
def labelspot(value)
unless value.nil? then
@lblWhere = value
label(@label.text) if @lblPlaced
end
@lblWhere
end
def method_missing(sym, *args)
if @list.respond_to?(sym) then
@list.send(sym, *args)
else
super(sym, *args)
end
end
alias old_respond_to respond_to?
def respond_to?(sym)
return true if old_respond_to(sym)
return true if @list.respond_to?(sym)
return false
end
end
-------------------------------------
My question is why doesn't the listbox in the TkScrollingListbox
expand and fill the frame when the frame gets more space -- I made it
sticky(news)... do I have a misunderstanding of the grid layout
manager? Is the world completely topsy turvy? Please help! Thanks