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

  • Home
  • SEARCH
  • 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 6162079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:35:31+00:00 2026-05-23T21:35:31+00:00

gtk.Builder is capable to identify all signals that a GUI (described in a XML

  • 0

gtk.Builder is capable to identify all signals that a GUI (described in a XML file) can emit and with the method connect_signals() automagically matches signals and handlers. Example:

class Gui(gobject.GObject):

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

    def on_whatever_gui_event(self, widget, data=None):
        ...

In my application I have other signals that are generated by non-GUI objects (it’s my Model [as in the MVC pattern] that emits a signal when its internal state is changed) but that need to be handled by the GUI.

I am trying to find a method that would allow me to automagically connect to the Gui instance also my custom signals. In other word, I’m trying not to have to manually connect each signal to it’s handler. Ideally the final code should look like:

class Gui(gobject.GObject):

    def __init__(self, model_instance):
        self.gui_file = "../data/gui.xml"
        builder = gtk.Builder()
        builder.add_from_file(self.gui_file)
        builder.add_signals_from_my_object(model_instance)
        builder.connect_signals(self)

    def on_whatever_gui_event(self, widget, data=None):
        ...

    def on_whatever_model_event(self, widget, data=None):
        ...

Is there a standard [py]GTK way to achieve this or do I have to write my own child class of gtk.Builder?

Thank you in advance for your time!

  • 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-23T21:35:31+00:00Added an answer on May 23, 2026 at 9:35 pm

    GtkBuilder takes the names to connect to from the XML, it does not search for methods starting with ‘on’. This means your model needs to be represented in the XML, there is no way to pass GtkBuilder a widget you instantiated in code. Glade has documentation on custom widgets.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have heard that GTK covers all controls so that developers do not care
Can GTK#'s FileChooserDialog be used as a unified file/URI dialog? I'd like it to
gtk.Builder.connect_signals() issues a RuntimeWarning when a signal handler is not present: __init__.py:16: RuntimeWarning: missing
Gtk programs can have different keybinding themes by binding different keys to gtk signals,
In GTK (or pygtk or gtkmm...) How can I detect that an application window
I can use GTK allocation function, but that only gives the position relative to
When Gtk GUI is started seems that Gtk sets optimal focus order to his
I'm trying to use custom container widgets in gtk.Builder definition files. As far as
Question regarding GtkBuilder. When we unref builder pointer does it destroys all the screens/widgets
I'm using GTK Sharp to work on some GUI for my app. Take a

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.