From: ts Date: 2001-03-24T00:15:37+09:00 Subject: [ruby-talk:13140] Re: TextBox ListBox >>>>> "R" == Ron Jeffries writes: R> OK, the qualifying trick didn't work ... I can't figure out what the R> qualifying syntax should be to get the code inside the proc refer to R> the instance variable of the class. Use something like this (see selfi and selfi.keyListbox) class HashBrowserView attr :keyListbox, true def initialize(aDictionary) @dictionary = aDictionary @methodListWidget = nil hashBrowserView = TkRoot.new {|w| title("Dictionary Browser") #positionWindow(w) } hashBrowserView.bind("Control-s", proc {save}) @keyListbox = nil selfi = self TkFrame.new(hashBrowserView, 'borderwidth'=>10) {|w| s = TkScrollbar.new(w) selfi.keyListbox = TkListbox.new(w) { setgrid 1 width 10 height 12 selectmode 'single' yscrollcommand proc{|first,last| s.set first,last} } s.command(proc{|*args| @keyListbox.yview *args}) s.pack('side'=>'right', 'fill'=>'y') selfi.keyListbox.pack('side'=>'left', 'expand'=>1, 'fill'=>'both') }.pack('side'=>'top', 'expand'=>'yes', 'fill'=>'y') @dictionary.keys.each { |key| @keyListbox.insert('end', key) } [etc, ...] Guy Decoux