pythongtkgtkbuilder

Set widget properties using GTKBuilder and Python


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)


Solution

  • 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").