Note that there are some explanatory texts on larger screens.

plurals
  1. POpygtk glade question: why isn't this simple script working?
    primarykey
    data
    text
    <p>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:</p> <pre><code>Traceback (most recent call last): File "test.py", line 7, in &lt;module&gt; class TestClass: File "test.py", line 10, in TestClass self.wTree.signal_autoconnect(self) NameError: name 'self' is not defined </code></pre> <p>Here is the contents of test.py:</p> <pre><code>#!/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() </code></pre> <p>And here is the glade file, test.glade:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt; &lt;!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd"&gt; &lt;!--Generated with glade3 3.4.5 on Fri Nov 21 08:53:53 2008 --&gt; &lt;glade-interface&gt; &lt;widget class="GtkWindow" id="TestWindow"&gt; &lt;property name="visible"&gt;True&lt;/property&gt; &lt;property name="title" translatable="yes"&gt;Test Window&lt;/property&gt; &lt;signal name="destroy" handler="on_TestClass_destroy"/&gt; &lt;child&gt; &lt;placeholder/&gt; &lt;/child&gt; &lt;/widget&gt; &lt;/glade-interface&gt; </code></pre> <p>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.</p> <p>I really don't understand why this isn't working, as I've created several other window classes that work fine.</p> <p>Is the following code working for anyone here?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload