I'm still muddling my way through the PyGTK tutorial in my spare moments. I've come across an interesting error and search engines have been of no help narrowing it down.
Here's the code, typed verbatim from the tutorial sans comments:
Code:
#!/usr/bin/env python
import pygtk
import gtk
class HelloWorld2:
def callback(self, widget, data):
print "Hello again - %s was pressed." % data
def delete_event(self, widget, event, data=None):
gtk.main.quit()
return False
def __init__(self):
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.set_title("Hello Buttons!")
self.window.connect("delete_event", self.delete_event)
self.window.set_border_width(10)
self.box1 = gtk.Hbox(False, 0)
self.window.add(self.box1)
self.button1 = gtk.Button("Button 1")
self.button2 = gtk.Button("Button 2")
self.button1.connect("clicked", self.callback, "button number 1")
self.button2.connect("clicked", self.callback, "button number 2")
self.box1.pack_start(self.button1, True, True, 0)
self.box1.pack_start(self.button2, True, True, 0)
self.button1.show()
self.button2.show()
self.box1.show()
self.window.show()
def main():
gtk.main()
if __name__ == "__main__":
hello = HelloWorld2()
main()
And here's the resulting error message when I run it in the terminal after making it executable:
Code:
Traceback (most recent call last):
File "./Upgraded Hello World.py", line 37, in <module>
hello = HelloWorld2()
File "./Upgraded Hello World.py", line 20, in __init__
self.box1 = gtk.Hbox(False, 0)
AttributeError: 'module' object has no attribute 'Hbox'
I'm importing gtk; I cannot imagine why the python interpreter would think there was no such thing as an HBox. I've looked this error up everywhere I know to, but it's apparently not a common one.
Any leads on how to track this one down would be duly appreciated. You guys are spoiling me with all your recent help.
Bookmarks