Re: [Python] passare variabili tra funzioni (pygtk)
On Fri, May 11, 2012 at 10:07 PM, Matteo Perini wrote: > Grazie mille oggi al lavoro ho risolto vedendo proprio questo esempio l'esempio te l'avevo ripulito un po' da quello del tutorial pygtk per renderlo più semplice e leggibile, mi fa piacere che comunque hai risolto. > (scusatemi ma mi sono dimenticato di aggiornarvi). ma mica ti devi scusare, anzi per il quote selvaggio un po' si :) > In effetti la soluzione è di passare l'oggetto "entry" alla nuova funzione. > Dovete scusare la domanda banale ma sto imparando e alcune cose non mi sono > ancora familiari. ciao buona serata -- Gian Mario Tagliaretti GNOME Foundation member gia...@gnome.org ___ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python
Re: [Python] passare variabili tra funzioni (pygtk)
Il 11/05/2012 20:37, Gian Mario Tagliaretti ha scritto: 2012/5/11 Matteo Perini: Ciao a tutti, ciao Matteo, posta un esempio completo anche se non funzionante, è più facile aiutarti, adesso sparo e vediamo se prendo il piccione... La textbox: self.entry1 = gtk.Entry() self.num_grab=self.entry1.get_text() Il button: self.button1 = gtk.Button("Grab Image") self.button1.connect("clicked", self.get_image) Nella class Window ho anche la funzione che voglio richiamare col button: def get_image(self,widget): self.num_grab= Window.win_take_pictures print self.num_grab #!/usr/bin/env python import pygtk pygtk.require('2.0') import gtk class EntryExample: def press_callback(self, widget, entry): entry_text = entry.get_text() print "Entry contents: %s\n" % entry_text def __init__(self): window = gtk.Window(gtk.WINDOW_TOPLEVEL) window.set_size_request(200, 100) window.set_title("Entry Example") window.connect("delete_event", lambda w,e: gtk.main_quit()) vbox = gtk.VBox(False, 0) window.add(vbox) vbox.show() entry = gtk.Entry() entry.connect("activate", self.press_callback, entry) entry.set_text("stampami") vbox.pack_start(entry, True, True, 0) entry.show() button = gtk.Button(stock=gtk.STOCK_EXECUTE) button.connect("clicked", self.press_callback, entry) vbox.pack_start(button, True, True, 0) button.set_flags(gtk.CAN_DEFAULT) button.grab_default() button.show() window.show() def main(): gtk.main() return 0 if __name__ == "__main__": EntryExample() main() ciao Grazie mille oggi al lavoro ho risolto vedendo proprio questo esempio (scusatemi ma mi sono dimenticato di aggiornarvi). In effetti la soluzione è di passare l'oggetto "entry" alla nuova funzione. Dovete scusare la domanda banale ma sto imparando e alcune cose non mi sono ancora familiari. Buona serata Matteo P ___ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python
Re: [Python] passare variabili tra funzioni (pygtk)
2012/5/11 Matteo Perini : > Ciao a tutti, ciao Matteo, posta un esempio completo anche se non funzionante, è più facile aiutarti, adesso sparo e vediamo se prendo il piccione... > La textbox: > self.entry1 = gtk.Entry() > self.num_grab=self.entry1.get_text() > > Il button: > self.button1 = gtk.Button("Grab Image") > self.button1.connect("clicked", self.get_image) > > Nella class Window ho anche la funzione che voglio richiamare col button: > def get_image(self,widget): > self.num_grab= Window.win_take_pictures > print self.num_grab #!/usr/bin/env python import pygtk pygtk.require('2.0') import gtk class EntryExample: def press_callback(self, widget, entry): entry_text = entry.get_text() print "Entry contents: %s\n" % entry_text def __init__(self): window = gtk.Window(gtk.WINDOW_TOPLEVEL) window.set_size_request(200, 100) window.set_title("Entry Example") window.connect("delete_event", lambda w,e: gtk.main_quit()) vbox = gtk.VBox(False, 0) window.add(vbox) vbox.show() entry = gtk.Entry() entry.connect("activate", self.press_callback, entry) entry.set_text("stampami") vbox.pack_start(entry, True, True, 0) entry.show() button = gtk.Button(stock=gtk.STOCK_EXECUTE) button.connect("clicked", self.press_callback, entry) vbox.pack_start(button, True, True, 0) button.set_flags(gtk.CAN_DEFAULT) button.grab_default() button.show() window.show() def main(): gtk.main() return 0 if __name__ == "__main__": EntryExample() main() ciao -- Gian Mario Tagliaretti GNOME Foundation member gia...@gnome.org ___ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python
[Python] passare variabili tra funzioni (pygtk)
Ciao a tutti, Ho costruito una semplice gui con pygtk e glade. In una finestra ho una textbox e un buttton. Quando premo il button vorrei venisse richiamata una funzione alla quale dovrebbe essere passato il numero inserito nella textbox. nella funzione win_take_pictures della class Window ho: La textbox: self.entry1 = gtk.Entry() self.num_grab=self.entry1.get_text() Il button: self.button1 = gtk.Button("Grab Image") self.button1.connect("clicked", self.get_image) Nella class Window ho anche la funzione che voglio richiamare col button: def get_image(self,widget): self.num_grab= Window.win_take_pictures print self.num_grab Vorrei (per adesso) che la funzione get_image mi stampasse a schermo il numero inserito nella textbox(self.num_grab). Ho provato a passare il parametro richiamando qualcosa del tipo self.get_image(self.num_grab) ma non sono riuscito. Scusate la domanda forse banale ma non ne sto uscendo... e anche google non mi ha aiutato molto. Ciao Grazie Matteo P ___ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python