On Mon, 2009-10-26 at 13:44 +0800, eric wrote: > I use pygtk develop a program, demand is this: > The main window to pop up a sub-window, some of the data entered > above, and then click "OK" button, obtain input and processed into the > database and finally close it. > > Now that is what I resolved: > 2 windows each corresponding to a class, the main window create the > child window and pass it's address into the child window , sub-window > get user input and calls the main window methods to perform data > processing. > > Such a solution did not feel good, is there any better way? For > example: transfer messages...etc > on windows, i can send messages between window, I would like to know > what is normal practice on pygtk.
In my opinion, the "pygtk way" if there is such a thing, is to make greater use of signals father than function callbacks explicitly. The following pseudocode might give you some ideas; class OtherW(gtk.Window) def get_data_user_entered(self): return 42 class W(gtk.Window): def user_clicked_button(self): self.ow = OtherW() self.ow.button.connect("clicked", self._get_data) def _get_data(self, *args): data = self.ow.get_data_user_entered() w = W() w.show_all() gtk.main() > _______________________________________________ > pygtk mailing list pygtk@daa.com.au > http://www.daa.com.au/mailman/listinfo/pygtk > Read the PyGTK FAQ: http://faq.pygtk.org/ _______________________________________________ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/