<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">---------- Forwarded message ----------<br>From: MRAB <<a href="mailto:python@mrabarnett.plus.com">python@mrabarnett.plus.com</a>><br>
To: <a href="mailto:python-list@python.org">python-list@python.org</a><br>Date: Sun, 13 Sep 2009 19:44:30 +0100<br>Subject: Re: AttributeError: 'NoneType' object has no attribute 'get_text'<br>Raji Seetharaman wrote:<br>

<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi all,<br>
i did a small gui addressbook application using pygtk, python, mysql db. It was successful.<br>
I tried the same application with glade. But i ended up with errors.<br>
I desgined the code as follows.<br>
1.It has one main window and four child dialogs.<br>
2.In the main window, i have to fill in the text entry widget & if i press 'add', the data will get inserted into the database.This works fine.<br>
3. If showdialog button is clicked, a child dialog appears, where i have to enter old entry to update.<br>
4. To update, i again use the main window, where i get the following error<br>
                  Traceback (most recent call last):<br>
  File "addressbookglade.py", line 63, in update<br>
    self.ssn = self.wTree.get_widget("ssn").<br>
get_text()<br>
    AttributeError: 'NoneType' object has no attribute 'get_text'<br>
<br>
Also i already set the name in properties window.  It works fine for add option. But not for update option.<br>
Im using the same window for both add and update.<br>
<br>
The code is available here <a href="http://pastebin.com/m28a4747e" target="_blank">http://pastebin.com/m28a4747e</a><br>
The glade xml file is here <a href="http://pastebin.com/m1af61a29" target="_blank">http://pastebin.com/m1af61a29</a><br>
The screenshot of my glade windows are here <a href="http://www.flickr.com/photos/raji_me/?saved=1" target="_blank">http://www.flickr.com/photos/raji_me/?saved=1</a><br>
 It works fine for add option. But not for update option. Im using the same window for both add and update.<br>
<br>
</blockquote>
You're using instance attributes a lot where I think local variables<br>
would be better, eg "self.ssn" instead of just "ssn".<br>
<br>
In the '__init__' method you have:<br>
<br>
    self.wTree = gtk.glade.XML(self.gladefile,"mainWindow")<br>
<br>
and then in the 'view' method you have:<br>
<br>
    self.wTree = gtk.glade.XML(self.gladefile,"viewdialog")<br>
<br>
In both the 'add' and 'update' methods you have:<br>
<br>
    self.ssn = self.wTree.get_widget("ssn").get_text()<br>
<br>
so I suspect that the following is happening:<br>
<br>
1. __init__ makes self.wTree refer to 'mainWindow';<br>
<br>
2. You click on the Add button, the 'add' method is called, and the "self.ssn = " line looks for the "ssn" widget in 'mainWindow';<br>
<br>
3. You click on the OK(?) button and view what's just been added;<br>
<br>
4. The 'view' method makes self.wTree refer to 'viewdialog';<br>
<br>
5. You click on the Update button, the 'update' method is called, and the "self.ssn = " line looks for the "ssn" widget in 'viewdialog'.<br></blockquote><div><br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<br>
Yes, u r right, the "self.ssn = " looks for widget in the child dialog, not the mainWindow. But how to set it to 'mainWindow' again.<br></blockquote></div>