In a treeview/liststore, I'm trying to figure out how to catch a mouseclick and return the data from that particular row...perhaps by connecting a signal to a treeview or something? I'd love input from anyone who's familiar w/ pygtk...thanks.
In a treeview/liststore, I'm trying to figure out how to catch a mouseclick and return the data from that particular row...perhaps by connecting a signal to a treeview or something? I'd love input from anyone who's familiar w/ pygtk...thanks.
Last edited by stateq2; January 8th, 2005 at 11:43 PM.
Yep, signal to treeview on click or mouse down event then grab the current row(s) from teh tree/list store. Don't have any examples off hand...
Do you have any links to the documentation of the pygtk api? I'd really appreciate it (and go write some nice-looking gnome-apps)!
You can find an API reference here: http://www.pygtk.org/reference.html
I'm sure I've done what you are asking before, but I also don't have any examples of getting the current row at the moment...
We rarely notice freedom. What we notice is the lack of freedom, and I'm afraid by then it is too late.
Be a good Ubuntu citizen - Report bugs || http://programmer-art.org
Ah, thanks!Originally Posted by Daniel G. Taylor
thanks, that's the basic idea. I did a little more searching and found this pageOriginally Posted by iwasbiggs
http://www.async.com.br/faq/pygtk/in...ick&req=search
so basically, I added an event to my treeview, as well as connected the signal:
the signal was to this callback:Code:self.treeview.add_events(gtk.gdk.BUTTON_PRESS_MASK) self.treeview.connect('button_press_event', self.selectTest)
and it worked great thanks for the info.....now to impliment threadingCode:def selectTest(self, widget, event): if event.button == 1 and event.type == gtk.gdk._2BUTTON_PRESS: print 'left double click' #get data from highlighted selection treeselection = self.treeview.get_selection() (model, iter) = treeselection.get_selected() name_of_data = self.liststore.get_value(iter, 0) #do something w/ 'name_of_data' here
Be careful with GTK + threading!Originally Posted by stateq2
Only access the GUI from a single thread (or use a queued dispatcher)!
If you start to get seemingly random segmentation faults, it's most likely that different threads are touching data simultaneously or when they aren't supposed to.
Check out (I think) gtk_threads_init or something like that and secure your variables with locks/semaphores.
Alternatively check out gobject.timeout_add(milliseconds, function) (newest development pygtk version, for older versions use gtk.timeout_add). That will call function() every so many milliseconds and you can update your GUI that way. For an example, I use it with my Key Status Monitor app.
We rarely notice freedom. What we notice is the lack of freedom, and I'm afraid by then it is too late.
Be a good Ubuntu citizen - Report bugs || http://programmer-art.org
I almost got it, but there's a small problem...so here's the quick question about threading.....
the following won't work right
but this willCode:threading.Thread(target=myClass.func(foo)).start()
'foo' is an argument passed to 'myClass.func()'. for some reason, threading doesn't work when I do this. is there any way I can pass an argument to this function? thanksCode:threading.Thread(target=myClass.func).start()
edit:
problem fixed....
....did the trickCode:threading.Thread(target=myClass.func, args=(foo, )).start()
Last edited by stateq2; January 14th, 2005 at 08:45 AM.
Bookmarks