From: thiago damasceno Date: 2010-05-16T01:07:25+09:00 Subject: Re: Wx Ruby - MenuBar. What's wrong with my code? --0016363ba6fcd937c20486a42f29 Content-Type: text/plain; charset=UTF-8 On Sat, May 15, 2010 at 12:59 PM, Ivo Roupa wrote: > Hi all, > > I have created a basic frame and I'm trying to create a MenuBar inside > it but although I have followed the API Documentation instructions I > always get this error. > > This is my code > > > require 'wx' > include Wx > > > class MyFrame < Wx::Frame > def initialize > super(nil,-1,'MinApp') > > @panel = Wx::Panel.new(self) > @menu_bar = Wx::MenuBar.new( > 2, > ['File','Edit','Help'], > ['Open','Save','Exit'], > 0) > show > end > end > > > class MinApp < App > def on_init > frame = MyFrame.new > end > end > > MinApp.new.main_loop > > And this is the error: > > C:/Documentos/Ruby Scripts/Frame_Ivo/lib/Ivo.rb:13:in `initialize': > wrong # of arguments(4 for 0) (ArgumentError) > from C:/Documentos/Ruby Scripts/Frame_Ivo/lib/Ivo.rb:13:in `new' > from C:/Documentos/Ruby Scripts/Frame_Ivo/lib/Ivo.rb:13:in > `initialize' > from C:/Documentos/Ruby Scripts/Frame_Ivo/lib/Ivo.rb:31:in `new' > from C:/Documentos/Ruby Scripts/Frame_Ivo/lib/Ivo.rb:31:in `on_init' > from C:/Documentos/Ruby Scripts/Frame_Ivo/lib/Ivo.rb:35:in `main_loop' > from C:/Documentos/Ruby Scripts/Frame_Ivo/lib/Ivo.rb:35:in `
' > > Thanks in advance for any help > > Ivo Roupa > -- > Posted via http://www.ruby-forum.com/. > > Hi Ivo, the constructor for Wx::MenuBar doesn't accept any arguments, you have to write you code in another way to achieve what you want. Thiago Brandao --0016363ba6fcd937c20486a42f29--