Hey fellas, relatively new to the community. I've started off this next college semester with various coding projects, and some of them involve the development of interfaces. I chose PyGTK for such a task -- I may try out Glade some time in the future just to see what the workflow is like.
As of right now, I'm pretty new with GUI coding, and I've found myself rather irritated with this snippet here off of PyGTK's tutorial (note that the comments were removed for clarity):
#!/usr/bin/env python
# example helloworld2.py
import pygtk
pygtk.require('2.0')
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.button1.connect("clicked", self.callback, "button 1")
self.box1.pack_start(self.button1, True, True, 0)
self.button1.show()
self.button2 = gtk.Button("Button 2")
self.button2.connect("clicked", self.callback, "button 2")
self.box1.pack_start(self.button2, True, True, 0)
self.button2.show()
self.box1.show()
self.window.show()
def main():
gtk.main()
if __name__ == "__main__":
hello = HelloWorld2()
main()
The issue I'm having is that, once I put this through my terminal with "chmod a+x HelloWorld.py" to make it an executable, once trying it out, I'm getting the "HelloWorld2" not recognized / undefined error.
Does anyone have any insight as to why this is the case?
Thanks a bunch, and I hope to hear from you guys soon.
Akratix