开发者

" wrong number of arguments" error in frame class initialization in wxRuby

开发者 https://www.devze.com 2023-03-24 23:54 出处:网络
I am trying to find my bearings using wxRuby, and am using this, perhaps outdated, tutorial with ruby 1.9.2p180 (2011-02-18) [i386-mingw32]

I am trying to find my bearings using wxRuby, and am using this, perhaps outdated, tutorial with ruby 1.9.2p180 (2011-02-18) [i386-mingw32]

This:

class MinimalApp < App
  def on_init
     Frame.new(nil, -1, "GUI Mockup").show()
  end
end

works: brings up an empty window. However, when I try to add a frame to the window, as so:

class MyFrame < Frame
  def initialize()
  super(nil, -1, 'My Frame Title')
 end
end

and change "Frame.new(... " to "MyFrame.new" I get the following error:

C:/.../wxTest.rb:8:in `initialize': wrong number of arguments (3 for 0) (ArgumentError)
    from C:/.../wxTest.rb:19:in `new'
    from C:/.../wxTest.rb:19:in `on_init'
 开发者_StackOverflow   from C:/.../wxTest.rb:24:in `main_loop'
    from C:/.../wxTest.rb:24:in `<main>'

At this point I am kind of stuck. I would be grateful for any suggestions.


OK, so seconds after posting, I answerd my own question. The problem was that

 MyFrame.new.(nil, -1, "Multipass GUI Mockup").show()

sets the options twice, or something. Changing it to

 MyFrame.new.show()

did the trick.

D'oh!

0

精彩评论

暂无评论...
验证码 换一张
取 消