Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1009105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:52:28+00:00 2026-05-16T08:52:28+00:00

Environment: Built interface using Glade3. Backend is written in Python using the GTK+ Builder

  • 0

Environment:

  • Built interface using Glade3.
  • Backend is written in Python using the GTK+ Builder library.

–

Although I know the method I need to use to update a label’s text (label.set_text(“string”)), I’m having trouble obtaining the label object in the python code.

Here’s what my code looks like:

#!/usr/bin/python
# Filename: HelloPython.py
# Author: Andrew Hefley Carpenter
# Date: 18 August 2010

import sys
import gtk

class HelloPython:

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

    def __init__(self):

        builder = gtk.Builder()
        builder.add_from_file("HelloPython.xml") 

        self.window = builder.get_object("window")
        builder.connect_signals(self)   

    def on_button1_clicked(self, widget):

        print "Hello World!"  
        widget.set_label("Hello World!")
        #I'd like to update 

if __name__ == "__main__":
    editor = HelloPython()
    editor.window.show()
    gtk.main()

End goal: I want to update “Object X” using it’s set_text method after the callback to “Object Y” (in this case button1) as handled by “on_button1_clicked”

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T08:52:29+00:00Added an answer on May 16, 2026 at 8:52 am

    The widget parameter to on_button1_clicked is a gtk.Button, not a gtk.Label. gtk.Button has a convenience api method called set_label().

    This only works if the child of Gtk.Button is a gtk.Label. This is the default when creating a new button in Glade-3, but if you’ve changed the contents of the button, this will not work and you’ll need a reference to the gtk.Label widget itself.

    EDIT (code to update the label):

    class HelloPython:
        def on_window_destroy(self, widget, data=None):
            gtk.main_quit()
    
        def __init__(self):
            builder = gtk.Builder()
            builder.add_from_file("HelloPython.xml") 
            self.window = builder.get_object("window")
            self.label = builder.get_object("label1") # get reference to the label
            builder.connect_signals(self)   
    
        def on_button1_clicked(self, widget):
            #widget.set_label("Hello World!") this would set the button's text
            self.label.set_text("Hello World!") # this sets the label's text
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've built a Django web application and some Django-Piston services. Using a web interface
I've built an R/Java interface in eclipse which works on my machine. I need
Trying to prepare good build environment for my js library. According to reviews on
Currently all our GUI components are written in MFC. Our build environment is: VC
project: Using VB.NET to build a winforms database interface and work-automation app. I am
project: Using VB.NET to build a winforms database interface and work-automation app. I am
We have a heterogeneous environment where some developers are using OSX and some are
We using an automated build system which downloads and compiles source. The only interface
STL Binary Interfaces I'm curious to know if anyone is working on compatible interface
Question/Environment The goal of my web application is to be a handy interface to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.