glade/pygtk trouble on Red Hat 9

W

Will Ware

In July there was a thread about problems on Red Hat 9 with PyGTK
not playing nice with Glade. I was tinkering with this a little bit
tonight, starting with the code I found in this article:
http://www.linuxjournal.com/article.php?sid=6586

Based on what was written, I tried this and had no joy:
######################################
import gtk
import gtk.glade
class BadGui:
def __init__(self):
gladefile = "project1.glade"
windowname = "window1"
self.wTree = tree = gtk.glade.XML(gladefile, windowname)
d = { }
for name in dir(self.__class__):
d[name] = getattr(self, name)
tree.signal_autoconnect(d)
gtk.mainloop()
def on_button1_clicked(self, *args):
print "button 1 clicked"
gtk.mainquit()
def on_button2_clicked(self, *args):
print "button 2 clicked"
def on_window1_destroy(self, *args):
print args
gtk.mainquit()
BadGui()
###################################

After some puttering, I came up with the following, which
works just fine:
########################################
import gtk
import gtk.glade
class GoodGui:
def __init__(self):
gladefile = "project1.glade"
windowname = "window1"
self.wTree = tree = gtk.glade.XML(gladefile, windowname)
for name in dir(self.__class__):
if name.startswith("on_"):
widgetname = name.split("_")[1]
widget = tree.get_widget(widgetname)
action = name[4 + len(widgetname):]
widget.connect(action, getattr(self, name))
gtk.mainloop()
def on_button1_clicked(self, *args):
print "button 1 clicked"
gtk.mainquit()
def on_button2_clicked(self, *args):
print "button 2 clicked"
def on_window1_destroy(self, *args):
print args
gtk.mainquit()
GoodGui()
########################################

As far as I can tell, there seems to be a problem with
signal_autoconnect, either how it's implemented in libglade
or how it gets connected to Python. Anyway, I'm passing this
along for any who might find it helpful.
 
P

P

Will said:
In July there was a thread about problems on Red Hat 9 with PyGTK
not playing nice with Glade. I was tinkering with this a little bit
tonight, starting with the code I found in this article:
http://www.linuxjournal.com/article.php?sid=6586

Based on what was written, I tried this and had no joy:

As far as I can tell, there seems to be a problem with
signal_autoconnect, either how it's implemented in libglade
or how it gets connected to Python. Anyway, I'm passing this
along for any who might find it helpful.

Never had a problem with signal_autoconnect (on redhat 7.x or above)
Have a look at the libglade module for either of the GUI apps here:
http://www.pixelbeat.org/talks/pygtk/
It's much the same as the code you posted but it's worth trying.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top