On Mon, August 20, 2012 6:59 am, Tristan Van Berkom wrote: > The "lookup_widget()" paradigm comes from a very old time when we > had very poor > tools and actually it originates from people using generated code from > the original Glade > tool (Glade versions 1 and 2). > > Ideally, as specially as you are using python, your application should > be modular. > > Perhaps you have an Application object which owns the main widgetry > created > by GtkBuilder after having parsed a Glade file initially, this is > different from a global > variable. > > Ideally you can use you object constructor as an entry point to load > your GtkBuilder > and assign the pointers you need later on to the members you define on > your > Application object. >
In this case I am programatically creating the widget. > After that you simply have to pass your Application object to all the > callbacks > which originate from the user interface, giving you access to everything > you > need when you need it. > This is the part I am having trouble with. > This concept can be further extended to be more modular, for instance if > you have a preferences dialog/window... it can be defined by a separate > python class/GtkBuilder file and reused at will throughout your program. > Thanks for your advice. I am planning to make this app as modular as possible but I am finding it hard to find a simple example that deals with my use case. Basically I want to be able to modify the text in a label widget from a Entry or EventBox signal. I haven't found an example of that but if anyone knows of one that would be very helpful. -- Patrick Shirkey Boost Hardware Ltd > Cheers, > -Tristan > > On Mon, Aug 20, 2012 at 1:10 PM, Patrick Shirkey > <pshir...@boosthardware.com> wrote: >> Hi, >> >> I'm having a little trouble finding examples online of using the >> equivalent of lookup_widget() with gtk3 + python. >> >> For example in the following code what is the best way to modify the >> "message" label after the "commandline" callback is sent? >> >> Should I be using globals or a glade file or is there a way to >> dynamically >> lookup the "message" widget ? >> >> >> >> def create_gtkEntry(): >> >> commandline = Gtk.Entry() >> commandline.connect("activate", command_entered, 1) >> >> messages = Gtk.Label('TEST') >> >> >> >> def command_entered(self, *args): >> >> cmi_command = self.get_text() >> messages.set_text(cmi_command) >> print "command entered: ", args[0] >> >> >> >> -- >> Patrick Shirkey >> Boost Hardware Ltd >> _______________________________________________ >> gtk-app-devel-list mailing list >> gtk-app-devel-list@gnome.org >> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > -- Patrick Shirkey Boost Hardware Ltd _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list