By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,271 Members | 1,722 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,271 IT Pros & Developers. It's quick & easy.

glade/pygtk trouble on Red Hat 9

P: n/a
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.

Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
P
Will Ware wrote:
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.

--
Pádraig Brady - http://www.pixelbeat.org

Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.