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 Answer 1

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

Sign up to request clarification or add additional context in comments.

1 Comment

In __init__ keep a reference to the builder object with self.builder = builder and in the callback use self.builder.get_object(objectname).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.