Hi, From: "Alan (Ursus Major)" <ursus / walkington.org> Subject: working with super? Date: Thu, 31 Oct 2002 09:58:56 +0900 Message-ID: <p7%v9.104765$tu.1081659 / news.easynews.com> > The following doesn't produce a visible scroll bar, but if I rewrite it > slighlty so that it calls TkListbox directly, it shows it. What am I doing > wrong here? The super(@ff, keys) calls TkListbox#initialize method. It does NOT call TkListbox#new method. TkListbox#initialize method does not use the given block. So, the block isn't evaluated. There are many solutions for the problem. One of them is --------------------------------- require 'tk' class FontBox < TkListbox def initialize(parent = nil, keys=nil) @ff = TkFrame.new super(@ff, keys) @lbox = self TkScrollbar.new(@ff, 'command'=>proc{|*args| lbox.yview *args}) {|s| pack('side'=>'right', 'fill'=>'y') lbox.yscrollcommand(proc{|first,last| s.set(first,last)}) } pack('side'=>'right', 'fill'=>'both', 'expand'=>'yes') @ff.pack TkFont.families.each{|fname| self.insert('end', fname.chomp) } end end fb = FontBox.new.pack Tk.mainloop --------------------------------- But, I think that it is better to use TkComposite module. tkscrollbox.rb is a sample to use the module, and it already installed on your ruby's library directory. :-) The result of the following script is similar to your script. --------------------------------- require 'tkscrollbox' fb = TkScrollbox.new.pack TkFont.families.each{|fname| fb.insert('end', fname.chomp)} Tk.mainloop --------------------------------- -- Hidetoshi NAGAI (nagai / ai.kyutech.ac.jp)