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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:25:09+00:00 2026-05-10T20:25:09+00:00

I’ve been writing writing a small pygtk application using glade to put together the

  • 0

I’ve been writing writing a small pygtk application using glade to put together the UIs. I’ve created several windows already that work, but for some reason this one isn’t working. I get the following traceback:

Traceback (most recent call last):   File 'test.py', line 7, in <module>     class TestClass:   File 'test.py', line 10, in TestClass     self.wTree.signal_autoconnect(self) NameError: name 'self' is not defined 

Here is the contents of test.py:

#!/usr/bin/env python  import pygtk import gtk import gtk.glade  class TestClass:     def __init__(self):         self.wTree = gtk.glade.XML('test.glade')         self.wTree.signal_autoconnect(self)      def on_TestClass_destroy(self, widget, data):         gtk.main_quit()  if __name__ == '__main__':     window = TestClass()     gtk.main() 

And here is the glade file, test.glade:

<?xml version='1.0' encoding='UTF-8' standalone='no'?> <!DOCTYPE glade-interface SYSTEM 'glade-2.0.dtd'> <!--Generated with glade3 3.4.5 on Fri Nov 21 08:53:53 2008 --> <glade-interface>   <widget class='GtkWindow' id='TestWindow'>     <property name='visible'>True</property>     <property name='title' translatable='yes'>Test Window</property>     <signal name='destroy' handler='on_TestClass_destroy'/>     <child>       <placeholder/>     </child>   </widget> </glade-interface> 

The strange thing is that if I take out the signal_autoconnect(self) call, the window opens. But if I replace that call with ‘self.on_TestClass_destroy(self, None, None)’ instead, it returns the same NameError exception.

I really don’t understand why this isn’t working, as I’ve created several other window classes that work fine.

Is the following code working for anyone here?

  • 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. 2026-05-10T20:25:10+00:00Added an answer on May 10, 2026 at 8:25 pm

    That code and window and signal connection work fine here.

    There is a small bug though when calling the signal handler. The signal handler should not have a data argument, since only the widget is passed as an argument.

    def on_TestClass_destroy(self, widget):     gtk.main_quit() 

    The data argument(s) are only those provided on connect in case you need extra state for a signal handler.

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

Sidebar

Related Questions

No related questions found

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.