Salve a tutti, come qualcuno avrà notato, mi sto cimentando con la interfaccia grafica con python coadiuvato da glade. Seguendo l'esempio su http://www.linuxjournal.com/article/6586 ho costruito la interfaccia su glade e salvata come "provafinestra.glade" e successivamente ho fatto copia ed incolla del codice che risulta come riportato sotto.
Purtroppo, però, quando avvio lo script il risultato è lo stallo del prompt del dos e una risposta su schermo che recita come segue: (python.exe:476): libglade-CRITICAL ** glade_xml_build_interface: assertion 'wid != NULL' failed premendo CTRL+C mi riporta, successivamente: Traceback (most recent call last): File "provafinestra.py", line 52, in (module) gtk.main() KeyboardInterrupt Cosa posso aver sbagliato? In fondo ho seguito alla lettera l'esempio... Il problema è che nessuna finestra è visibile... Qualche idea su cosa possa aver sbagliato? Grazie infinite. ------------------------------CODICE---------------- import sys try: import pygtk #tell pyGTK, if possible, that we want GTKv2 pygtk.require("2.0") except: #Some distributions come with GTK2, but not pyGTK pass try: import gtk import gtk.glade except: print "You need to install pyGTK or GTKv2 ", print "or set your PYTHONPATH correctly." print "try: export PYTHONPATH=", print "/usr/local/lib/python2.2/site-packages/" sys.exit(1) #now we have both gtk and gtk.glade imported #Also, we know we are running GTK v2 class appgui: def __init__(self): """ In this init we are going to display the main serverinfo window """ self.gladefile="provafinestra.glade" self.windowname="serverinfo" self.wTree=gtk.glade.XML(self.gladefile,self.windowname) # we only have two callbacks to register, but # you could register any number, or use a # special class that automatically # registers all callbacks. If you wanted to pass # an argument, you would use a tuple like this: # dic = { "on button1_clicked" : \ #39 (self.button1_clicked, arg1,arg2) , ... dic = { "on_button1_clicked" : self.button1_clicked, "on_serverinfo_destroy" : (gtk.mainquit) } self.wTree.signal_autoconnect (dic) return #####CALLBACKS def button1_clicked(self,widget): print "button clicked" # we start the app like this... app=appgui() gtk.main() -- Vittorio Zuccalà
_______________________________________________ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python