2

I am new with GTKBuilder. I have included a GTKBuilder file in my Python script. I want to change a property of a widget.

For example, if someone clicks on "More Information", on_more_information function gets triggered. I want to change the Label of Label lblConnectionStatus on the trigger.

import gtk

class RoyalBengalWiMAX:

    def __init__(self):
        filename = "gui.xml"
        builder = gtk.Builder()
        builder.add_from_file(filename)
        builder.connect_signals(self)

    def on_window1_destroy(self, widget, data=None):
        gtk.main_quit()

    def on_information_click(self, widget, data=None):




app = RoyalBengalWiMAX()
gtk.main()

How can I achieve that? (I couldn't include the GTKBuilder XML, stackoverflow says it's too large)

1 Answers1

3

Do you mean somethink along the lines of Label.set_text("new text")? If so, you probably first have to get the widget from the file using gtk.Builder.get_object("objectname").

phimuemue
  • 34,669
  • 9
  • 84
  • 115
  • 1
    In `__init__` keep a reference to the builder object with `self.builder = builder` and in the callback use `self.builder.get_object(objectname)`. – jcollado Jan 29 '12 at 16:38