Forse questa può essere d'aiuto/ispirazione? http://faq.pygtk.org/index.py?file=faq10.021.htp&req=show Lorenzo
Ciao lista,ho scritto alcuni esempi usando solo pygtk e le finestre si chiudono correttamente... (riesco a ri-aprirle!!).
Il problema però persiste sulla mia interfaccia.L'unica cosa in cui si differenzia dalle prove che ho fatto è che importo l'interfaccia da un file glade che ho creato a parte. Allego entrambi i file (non pretendo li guardiate..... ma se proprio volete ;-))
Ciao Matteo
import pygtk import gtk import gtk.glade import sys import subprocess global num class Window: def __init__(self): signals = { 'on_quit_button_clicked':self.on_quit_button_clicked, 'on_btn_take_picture_clicked':self.on_btn_take_picture_clicked, 'on_btn_take_object_clicked':self.on_btn_take_object_clicked, 'on_btn_stop_acquisition_clicked':self.on_btn_stop_acquisition_clicked, 'on_btn_main_calib_clicked':self.on_btn_main_calib_clicked, 'on_btn_reconstruction_clicked':self.on_btn_reconstruction_clicked } gladeFile = gtk.glade.XML(fname='Guiglade.glade') gladeFile.signal_autoconnect(signals) gw = gladeFile.get_widget self.win = gw('WinMain') self.win.connect("destroy", self.exit) self.quit_button=gw('quit_button') self.btn_take_picture=gw('btn_take_picture') self.btn_take_object=gw('btn_take_object') self.btn_stop_acquisition=gw('btn_stop_acquisition') self.btn_main_calib=gw('btn_main_calib') self.btn_reconstruction=gw('btn_reconstruction') self.win.show_all() def on_quit_button_clicked(self, widget): gtk.main_quit() return 0 def on_btn_take_picture_clicked(self,widget): self.win_take_pictures(self) def on_btn_take_object_clicked(self,widget): self.win_take_object(self) def on_btn_stop_acquisition_clicked(self,widget): self.convert_e_resize_images(self) def on_btn_main_calib_clicked(self,widget): self.main_calibration(self) def on_btn_reconstruction_clicked(self,widget): self.main_reconstruction(self) def main(self): gtk.main() def exit(self,widget): gtk.main_quit() sys.exit() return 0 def close_take_pictures(self,widget): self.win_take_pictures.destroy() return 0 def win_take_pictures(self, widget,data=None): def get_calib_image(self,entry,data=None): self.num = entry.get_text() subprocess.call(['./scan-firewire.py',self.num]) self.win_take_pictures = gtk.Window(gtk.WINDOW_TOPLEVEL) self.win_take_pictures.set_position(gtk.WIN_POS_CENTER) self.win_take_pictures.set_title("Acquisisci le immagini per la calibrazione") self.win_take_pictures.set_border_width(15) self.win_take_pictures.connect("destroy",self.close_take_pictures) hbox1 = gtk.HBox(True, 0) hbox2 = gtk.HBox(True, 0) vbox = gtk.VBox(True, 0) self.entry1 = gtk.Entry() self.entry1lab = gtk.Label("ciao") num=self.entry1.get_text() self.button1 = gtk.Button("Grab Image") self.button1.connect("clicked",get_calib_image, self.entry1) self.label1 = gtk.Label("Acquisizione numero:") hbox1.pack_start(self.label1, True, True, 5) hbox1.pack_start(self.entry1,True,True,5) hbox2.pack_start(self.button1, True, True, 5) vbox.pack_start(hbox1, True, False, 5) vbox.pack_start(hbox2, True, False, 5) self.win_take_pictures.add(vbox) self.win_take_pictures.show_all() def win_take_object(self, widget,data=None): def get_obj_image(self,entry): self.num = entry.get_text() subprocess.call(['./scan-firewire-obj.py',self.num]) self.win_take_object = gtk.Window(gtk.WINDOW_TOPLEVEL) self.win_take_object.set_position(gtk.WIN_POS_CENTER) self.win_take_object.set_title("Acquisisci le immagini per la calibrazione") self.win_take_object.set_border_width(15) hbox1 = gtk.HBox(True, 0) hbox2 = gtk.HBox(True, 0) vbox = gtk.VBox(True, 0) self.entry1 = gtk.Entry() self.entry1lab = gtk.Label("ciao") num=self.entry1.get_text() self.button1 = gtk.Button("Grab Image") self.button1.connect("clicked",get_obj_image, self.entry1) self.label1 = gtk.Label("Acquisizione oggetto numero:") hbox1.pack_start(self.label1, True, True, 5) hbox1.pack_start(self.entry1,True,True,5) hbox2.pack_start(self.button1, True, True, 5) vbox.pack_start(hbox1, True, False, 5) vbox.pack_start(hbox2, True, False, 5) self.win_take_object.add(vbox) self.win_take_object.show_all() #return self.num_grab def convert_e_resize_images(self,widget,data=None): subprocess.call(['./ConvertEResizeXpx','720']) print 'Fatto!' def main_calibration(self,widget,data=None): def calib1(self,entry): self.num = entry.get_text() print self.num subprocess.call(['./ordinaimmaginipiucalcolofaseconunwrapscipy.py',str(self.num)]) subprocess.call(['./Calibrazione_completa.py']) subprocess.call(['./xyzphi3.py']) print 'please wait....' subprocess.call(['./CalcoloCoefficienti_taratura.py']) def close_calib(self,main_calibration): main_calibration.destroy() return 0 self.main_calibration = gtk.Window(gtk.WINDOW_TOPLEVEL) self.main_calibration.set_position(gtk.WIN_POS_CENTER) self.main_calibration.set_title("Calibrazione") self.main_calibration.set_border_width(15) hbox1 = gtk.HBox(True, 0) hbox2 = gtk.HBox(True, 0) hbox3 = gtk.HBox(True, 0) vbox = gtk.VBox(True, 0) self.entry1 = gtk.Entry() self.entry1lab = gtk.Label("ciao") num=self.entry1.get_text() self.button1 = gtk.Button("Calibra") self.button1.connect("clicked",calib1, self.entry1) self.button_exit = gtk.Button("Exit") self.button_exit.connect("clicked",close_calib,self.main_calibration) self.label1 = gtk.Label("Numero di acquisizioni valide:") hbox1.pack_start(self.label1, True, True, 5) hbox1.pack_start(self.entry1,True,True,5) hbox2.pack_start(self.button1, True, True, 5) hbox3.pack_start(self.button_exit, True, True, 5) vbox.pack_start(hbox1, True, False, 5) vbox.pack_start(hbox2, True, False, 5) vbox.pack_start(hbox3, True, False, 5) self.main_calibration.add(vbox) self.main_calibration.show_all() def main_reconstruction(self,widget,data=None): def rec1(self,entry): self.num = entry.get_text() print self.num subprocess.call(['./Reconstruction.py',str(self.num)]) self.main_reconstruction = gtk.Window(gtk.WINDOW_TOPLEVEL) self.main_reconstruction.set_position(gtk.WIN_POS_CENTER) self.main_reconstruction.set_title("Ricostruzione") self.main_reconstruction.set_border_width(15) hbox1 = gtk.HBox(True, 0) hbox2 = gtk.HBox(True, 0) vbox = gtk.VBox(True, 0) self.entry1 = gtk.Entry() self.entry1lab = gtk.Label("ciao") num=self.entry1.get_text() self.button1 = gtk.Button("Ricostruisci ") self.button1.connect("clicked",rec1, self.entry1) self.label1 = gtk.Label("Numero oggetto da ricostruire:") hbox1.pack_start(self.label1, True, True, 5) hbox1.pack_start(self.entry1,True,True,5) hbox2.pack_start(self.button1, True, True, 5) vbox.pack_start(hbox1, True, False, 5) vbox.pack_start(hbox2, True, False, 5) self.main_reconstruction.add(vbox) self.main_reconstruction.show_all() self.show_all() if __name__ == "__main__": win = Window() win.main()
Guiglade.glade
Description: application/glade
_______________________________________________ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python