Forum: wxRuby My first wxRuby app doesn't work, please help!

6256f6891b1eeea6413acb78975f2f17?d=identicon&s=25 tuti plain (tutiplain)
on 2010-03-30 19:03
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.
6256f6891b1eeea6413acb78975f2f17?d=identicon&s=25 tuti plain (tutiplain)
on 2010-03-30 19:14
Never mind.  My constructors were all wrong.
8971d9516af2204098ec5712f51f7bb3?d=identicon&s=25 Adi Mou (adimou)
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
This topic is locked and can not be replied to.