I referred to wxRuby documentation to add Menu Bar and Menu on a Window,
but the code is not working.
I tried:
========== [CODE] ===========
class MinimalApp < App
def on_init
@frame = MDIParentFrame.new(nil,-1,'RubyPIM - [Main
Window]',Point.new(100,100),Size.new(1200,800)).show()
@menubar = MenuBar.new
@file = Menu.new
@open = @file.append("Open", "open")
@menubar.append(@file, "File")
@frame.set_menu_bar(@menubar)
end
end
=============================
I am getting error:
D:/Aptana Projects/RubyPIM/MainWindow.rb:13:in `on_init': undefined
method `set_menu_bar' for true:TrueClass (NoMethodError)
from D:/Aptana Projects/RubyPIM/MainWindow.rb:18:in `main_loop'
from D:/Aptana Projects/RubyPIM/MainWindow.rb:18:in `<main>'
on 2012-07-25 18:04
on 2012-07-25 19:30
Am Wed, 25 Jul 2012 18:04:24 +0200 schrieb Rubyist Rohit <lists@ruby-forum.com>: > @menubar = MenuBar.new > > D:/Aptana Projects/RubyPIM/MainWindow.rb:13:in `on_init': undefined > method `set_menu_bar' for true:TrueClass (NoMethodError) > from D:/Aptana Projects/RubyPIM/MainWindow.rb:18:in `main_loop' > from D:/Aptana Projects/RubyPIM/MainWindow.rb:18:in `<main>' > If you’re just starting out with wxRuby, why do you use MDI windows? These are quite complex windows, and for the beginning you’re far better off using ordinary frames. In your above code, @frame is set to `true', which is the return value of show. true doesn’t have a method #set_menu_bar, hence the exception. As said, for a minimal app you don’t want MDI windows. Try something like this: ================================================ require "wx" class MinimalApp < Wx::App include Wx def on_init @frame = Frame.new(nil, title: "Main window") @menubar = MenuBar.new menu = Menu.new @menubar.append(menu, "File") @frame.menu_bar = @menubar @frame.show end end MinimalApp.new.main_loop ================================================ Oh, and please read this one: http://wxruby.rubyforge.org/doc/wxruby_intro.html You don’t have to obey the C++-derived method documentation directly. wxRuby adds some nice and more rubyish wrappers around them. Vale, Marvin -- Blog: http://pegasus-alpha.eu/blog ASCII-Ribbon-Kampagne () | ASCII Ribbon Campaign () - Stoppt HTML-E-Mail /\ | - Against HTML E-Mail /\ - Stoppt proprietäre Anhänge | - Against proprietary attachments www.asciiribbon.org/index-de.html | www.asciiribbon.org
on 2012-07-25 19:34
I am new to Ruby and wxRuby as well. I started writing a real application which will make learning interesting. I therefore need an MDIWindow.
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.