Problem:
<code> >>> from Tix import * >>> root=Tk() >>> nb=NoteBook(root) >>> nb.add('pg_1', label='pg 1') >>> nb.pages() Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/local/lib/python2.4/lib-tk/Tix.py", line 1160, in pages ret.append(self.subwidget(x)) File "/usr/local/lib/python2.4/lib-tk/Tix.py", line 337, in subwidget raise TclError, "Subwidget " + name + " not child of " + self._name _tkinter.TclError: Subwidget p not child of -1211878740 </code>
Visiting Tix.py I found at line 1155 the following function:
<code> def
pages(self): # Can't call subwidgets_all directly because we don't want .nbframe names = self.tk.split(self.tk.call(self._w, 'pages')) ret = [] for x in names: ret.append(self.subwidget(x)) return ret </code>
The issue is that, for only one tab "names" is a string (the name of the tab), while for 2 or more it is a tuple of names of tabs. For an empty NoteBook, "names" is an empty string. The for loop in the case of one tab will go through the letters of the tab's name, and that is where subwidget fails.
Resolution: <code> def pages(self): # Can't call subwidgets_all
directly because we don't want .nbframe names = self.tk.split(self.tk.call(self._w, 'pages')) ret = [] if names and type(names) == type('a'): # sxn # 1 tab gives a string ret.append(self.subwidget(names)) # sxn # else: # sxn # 2+ tabs give a tuple for x in names: ret.append(self.subwidget(x)) return ret </code>
I am on Linux, Python 2.4.2, Tcl/Tk 8.4, Tix 8.2
Sorin
Everyone is raving about the all-new Yahoo! Mail beta. |