From: Peter Hickman Date: 2002-01-28T18:42:03+09:00 Subject: Problem with Ruby Tk I'm having some problems with the following code. When I click on either of the buttons on the scrollbar or move the thumb within the scrollbar the program crashes out on me. The error message that follows is from Windows 1.6.5-2 but the same error turns up on two seperate Linux installs. As the code is mostly cut and paste from the Pickaxe book I am somewhat baffled. BTW the Pickaxe code works fine but then it is not in a class. Any pointers? class Bugged require 'tk' def initialize root = TkRoot.new() { title 'There is a bug here' } frm_top = TkFrame.new(root) { pack('anchor' => 'w') } @text = TkText.new(root) { width 60 height 30 } scroll = TkScrollbar.new(root) { command proc { |*args| @text.yview *args} pack('side' => 'right', 'fill' => 'y') } @text.yscrollcommand(proc {|first, last| scroll.set(first,last)}) @text.pack('side' => 'left', 'expand' => 1, 'fill' => 'both') (1..50).each {|n| @text.insert('end', "This is line #{n}\n") } Tk.mainloop end end s = Bugged.new D:\My Documents>ruby bug.rbw (eval):606:in `mainloop': bug.rbw:17:in `initialize': undefined method `yview' for nil (NameError) from /cygdrive/c/RUBY/lib/ruby/1.6/tk.rb:606:in `mainloop' from bug.rbw:26:in `initialize' from bug.rbw:30:in `new' from bug.rbw:30