Hi, I'm trying to learn wxRuby. This is program:
require 'wx'
include Wx
class MyFrame < Frame
def initialize
super(nil,-1,"Mi primera ventana Wx!")
@panel = Panel.new(self)
@lbl1 = StaticText.new(@panel,-1,"Label")
@text1 = TextCtrl.new(@panel,-1,"Text Value")
@combo =ComboBox.new(@panel,-1,"Combo Text")
@button =Button.new(@panel,-1,"Submit")
#layout
@sizer = BoxSizer.new(VERTICAL)
@panel.set_sizer(@sizer)
evt_button(@my_button.get_id()) { |event| my_button_click(event)}
@sizer.add(@lbl1,0, GROW|ALL,2)
@sizer.add(@text1,0, GROW|ALL,2)
@sizer.add(@combo,0, GROW|ALL,2)
@sizer.add(@button,0, GROW|ALL,2)
show()
end
def my_button_click(event)
#añádir codigo
puts "Presionado"
end
end
class Myapp < App
def on_init
MyFrame.new
end
end
a= Myapp.new
a.main_loop()
When I run this, I get an illegal operation! I am using wxRuby 2.0.1,
Ruby 1.8 (one click installer version) and windows xp. Thanks for any
info.
on 2010-03-30 19:03
on 2010-05-24 23:52
Hi,
On error in your code :
evt_button(@my_button.get_id()) { |event| my_button_click(event)}
The correct :
evt_button(@button.get_id()) { |event| my_button_click(event)}
Good luck
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.