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 569309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:16:53+00:00 2026-05-13T13:16:53+00:00

Is it possible to create new signals in Python GTK+ ? I’d like a

  • 0

Is it possible to create new signals in Python GTK+ ?

I’d like a skeleton code example, please.

  • 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-13T13:16:53+00:00Added an answer on May 13, 2026 at 1:16 pm

    An excerpt:

    Creating your own signals

    The other thing you probably want to
    use when subclassing GObject is define
    custom signals. You can create your
    own signals that can be emitted so
    users of your class can connect to
    them.

    When a signal is emitted a set of
    closures will be executed. A closure
    is an abstraction of the callback
    concept. A closure is the callback
    itself (a function pointer), the user
    data (it will be the last parameter to
    the callback) and another function for
    cleanup issues, which will not be
    discussed in this document.

    For the sake of this article you don’t
    really need to know the difference
    between a callback and a closure so
    both terms will be used. But be
    advised that this is not totally
    correct.

    As we said before, when a signal is
    emitted, a set of closures will be
    executed. One of them is the same one
    for all the instances of this class
    and hence its name: the class closure,
    and the other ones are custom user
    callbacks. Note that not all the
    signals need to have a class closure
    because it is optional.

    From, http://www.pygtk.org/articles/subclassing-gobject/sub-classing-gobject-in-python.htm, hope that helps. There is example code on the site and here , a snippet:

    import pygtk
    pygtk.require('2.0')
    import gobject
    
    class Car(gobject.GObject):
        __gproperties__ = {
            'fuel' : (gobject.TYPE_FLOAT, 'fuel of the car',
                      'amount of fuel that remains in the tank',
                      0, 60, 50, gobject.PARAM_READWRITE)
            }
    
        __gsignals__ = {
            'engine-started' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
                                (gobject.TYPE_FLOAT,))
            }
    
        def __init__(self):
            gobject.GObject.__init__(self)
            self.fuel = 50
    
        def do_get_property(self, property):
            if property.name == 'fuel':
                return self.fuel
            else:
                raise AttributeError, 'unknown property %s' % property.name
    
        def do_set_property(self, property, value):
            if property.name == 'fuel':
                self.fuel = value
            else:
                raise AttributeError, 'unknown property %s' % property.name
    
        def do_engine_started(self, remaining_fuel):
            print '***** Beginning of class closure *****'
            print 'The engine is ready and we still have %f of fuel' % self.fuel
            print '***** End of class closure *****'
    
        def start(self):
            self.emit('engine-started', self.get_property('fuel'))
    
    gobject.type_register(Car)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I initally missed that you didnt have drivers for the… May 15, 2026 at 6:06 pm
  • Editorial Team
    Editorial Team added an answer is there anything else I should do to it to… May 15, 2026 at 6:06 pm
  • Editorial Team
    Editorial Team added an answer This multitude of small classes would drive me nuts. With… May 15, 2026 at 6:06 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

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.