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

Ask A Question

Stats

  • Questions 508k
  • Answers 508k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Load it into a Dictionary<int, string>, assuming the id field… May 16, 2026 at 4:19 pm
  • Editorial Team
    Editorial Team added an answer The /dev/urandom pseudo-device, along with dd, can do this for… May 16, 2026 at 4:19 pm
  • Editorial Team
    Editorial Team added an answer It's not clear which project type you've got - ASP.NET… May 16, 2026 at 4:19 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I've built a Django web application and some Django-Piston services. Using a web interface
This is a puzzler. Relevant Environment: Flex app, running parsley, which gets built by
I am making an automated build environment using ant to build a freshly checked
Fedora Core 9 seems to have FCGID instead of FastCGI as a pre-built, YUM-managed
Where I work we need to rethink the way we develop software and keep
I need a light css editor with certain functions. Already downloaded and tried a
I'm using Visual Studio to build my wix file. So far I have one
I have an idea for a new desktop environment that involves a radically different
I'm trying to set up my environment for developing, debugging and deploying Windows Desktop
I've built a JAR file and it executes fine on my PC (XP) which

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.