pygtk glade question: why isn't this simple script working?

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 "", line 7, in <module>
    class TestClass:
  File "", line 10, in TestClass
NameError: name 'self' is not defined

Here is the contents of

#!/usr/bin/env python

import pygtk
import gtk

class TestClass:
    def __init__(self):
        self.wTree ="")

    def on_TestClass_destroy(self, widget, data):

if __name__ == "__main__":
    window = TestClass()

And here is the glade file,

<?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 -->
  <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"/>

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?


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):

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

Need Your Help

Not able to install matplotlib on ubunut 12.04

python ubuntu matplotlib

I'm trying to install python-matplotlib on a Ubuntu 12.04 machine.

How do I find the current font size at bookmark?

vb6 ms-word

We are using VB6 and Word.Basic object to create documents. Text is inserted at a variety of bookmarks. Our latest requirement wants us to increase the font size for a given insert. We are currently

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.