quik77
October 28, 2006, 3:36am
1
Thanks: Not sure how you got your example working
though. Maybe you can give a piece of your code?
For me, I tried a bit more, and when i used this signal
instead:
button_release_event
and
puts widget.selection.selected[0]
all seems to be fine now.
One problem less on my list, getting
closer to finish that little MidnightCommander
clone.
–
Get your free email from http://www.linuxmail.org
Powered by Outblaze
Using Tomcat but need to do more? Need to support web services,
security?
Get stuff done quickly with pre-integrated technology to make your job
easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache
Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
quik77
October 28, 2006, 8:47am
2
Roebe XXX wrote:
puts widget.selection.selected[0]
all seems to be fine now.
One problem less on my list, getting
closer to finish that little MidnightCommander
clone.
i changed your code a bit.
this can do multiple selection, which you’ll need in a
gtk-mini-midnight-commander
#!/usr/bin/ruby
require ‘gtk2’
Gtk.init
SimpleTreeView.new
class SimpleTreeView
=== initialize
def initialize
@main_window = Gtk::Window.new
@main_window.set_size_request 555,255
create_parts
end
def create_parts
@renderer=Gtk::CellRendererText.new
@renderer.set_property ( ‘background’, ‘lavender’ )
@renderer.set_property ( ‘foreground’, ‘black’ )
@list_store = Gtk::ListStore.new(String)
@tree_view = Gtk::TreeView.new(@list_store)
@tree_view_column = Gtk::TreeViewColumn.new('Laaa',
@renderer, {:text => 0})
@tree_view.append_column(@tree_view_column)
# Example Data:
iter = @list_store.append
iter.set_value(0, 'aaa')
iter = @list_store.append
iter.set_value(0, 'bbb')
iter = @list_store.append
iter.set_value(0, 'ccc')
@tree_view.signal_connect (‘button_press_event’) do |widget,event|
puts "Selection was: "+widget.selection.selected[0]
end
@tree_view.selection.set_mode(Gtk::SelectionMode::MULTIPLE)
@tree_view.selection.signal_connect("changed"){|me|
print me.count_selected_rows," : "
me.selected_each {|model, path, iter|
print iter[0]," "
}
print "\n"
}
@main_window.add(@tree_view)
@main_window.show_all
Gtk.main
end
end
SimpleTreeView.new