TreeCtrl event help

hey could someone hel me cus I need to get the label for the selected
item when expanded but when I use the method evt_tree_expaded or
evt_tree_expanding it gives me nil like this:

require ‘wx’
include Wx
class MyFrame < Frame
def initialize
super(nil,
:title => “prueba”
)
@my_panel = Panel.new(self)
@my_label = StaticText.new(@my_panel,
:label => “MY”,
:pos => [150, 25],
:size => Wx::DEFAULT_SIZE)
@my_textbox = TextCtrl.new(@my_panel,
:name => “Default Textbox Value”,
:pos => [20, 20])
@my_combo = Wx::ComboBox.new(@my_panel,
:name => “Default Combo Text”,
:pos => [150, 25],
:choices => [‘Item 1’, ‘Item 2’, ‘Item 3’])
@my_button = Button.new(@my_panel, -1, ‘My Button Text’)
evt_button @my_button, :my_button_click
@my_panel_sizer = BoxSizer.new(VERTICAL)
@my_panel.set_sizer(@my_panel_sizer)
@my_panel_sizer.add(@my_label, 0, GROW|ALL, 2)
@my_panel_sizer.add(@my_textbox, 0, GROW|ALL, 2)
@my_panel_sizer.add(@my_combo, 0, GROW|ALL, 2)
@my_panel_sizer.add(@my_button, 0, GROW|ALL, 2)
show()
end
def get_name(eve)
@id = eve.get_item
@text = @tree.get_item_text(@id)
end
def my_button_click(event)
@dir_dialog = Dialog.new(nil,
:size => [400, 400])
@dir_view = GenericDirCtrl.new(@dir_dialog,
:size => [390, 340],
:dir => ENV[“HOME”] )
@dir_vsizer = VBoxSizer.new
@dir_dialog.set_sizer(@dir_vsizer)
@accept = Button.new(@dir_dialog,
:label => “Accept”,
:id => ID_OK)
@tree = @dir_view.get_tree_ctrl
evt_tree_item_expanded @tree, :get_name
@dir_vsizer.add(@dir_view, 0, 2)
@dir_vsizer.add(@accept, 0, GROW|ALL, 2)
case @dir_dialog.show_modal
when ID_OK
@tree_select = @tree.get_selection()
@tree_text = @tree.get_item_text(@tree_select)
#poner cheque por si no es carpeta mandarlo de regreso
#llamarlo usando el metodo dir_button_click
@my_label.label = @text
@dir_text.clear
@error_dialog = Dialog.new(nil,
:title => “Error”,
:size => [500, 100])
@error_text = StaticText.new(@error_dialog,
:label => “You must chose a folder”,
:style => ALIGN_CENTRE)
@ok_error = Button.new(@error_dialog,
:id => ID_OK)
@error_size = VBoxSizer.new
@error_dialog.set_sizer(@error_size)
@error_size.add(@error_text, 0, GROW|ALL, 2)
@error_size.add(@ok_error, 0, GROW|ALL, 2)
case @error_dialog.show_modal
when ID_OK
end
end
end
end
end
class MyApp < App
def on_init
MyFrame.new
end
end
MyApp.new.main_loop()

Is this the way its done or there is a better way please help

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs