[Python-bugs-list] [ python-Bugs-516703 ] Tix:NoteBook add/delete/add page problem
noreply@sourceforge.net
noreply@sourceforge.net
Wed, 27 Mar 2002 10:07:00 -0800
Bugs item #516703, was opened at 2002-02-13 00:21
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=516703&group_id=5470
Category: Tkinter
Group: Python 2.3
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Christoph Monzel (chris_mo)
Assigned to: Nobody/Anonymous (nobody)
Summary: Tix:NoteBook add/delete/add page problem
Initial Comment:
Problem: NoteBook add/delete/add page with the same
name does not work. python2.2/Tix
Example Python Script for reproducing the Bug:
import Tix
import rlcompleter
root=Tix.Tk()
notebook=Tix.NoteBook(root, ipadx=3, ipady=3)
notebook.add('general', label="General", underline=0)
notebook.add('displaymode', label="Display mode",
underline=0)
notebook.pack()
notebook.delete('general')
notebook.add('general', label="General", underline=0)
la=Tix.Label(notebook.general,text="hallo")
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.2/lib-tk/Tkinter.py", line
2261, in __init__
Widget.__init__(self, master, 'label', cnf, kw)
File "/usr/lib/python2.2/lib-tk/Tkinter.py", line
1756, in __init__
self.tk.call(
TclError: bad window path name
".135915860.nbframe.general"
Tix seems nothing to know about the new page
>>> notebook.tk.call(notebook._w,'pages')
'displaymode'
Analysis:
in NoteBook.add() the new "same named" widget will
succesfully created in tk. But it will be immediatly
removed, if the TixSubWidget is constructed
Solution:
In the Notebook class:
Do mark subwidget "destroy_physically=1". Also
for clearness delete entry from subwidget_list dict.
I dont't know if this is a fine or correct solution
but it works (for me)
Patch:
derrick:chris$ diff -u
/usr/lib/python2.2/lib-tk/Tix.py Tix.py
--- /usr/lib/python2.2/lib-tk/Tix.py Sun Nov 4
01:45:36 2001
+++ Tix.py Tue Feb 12 23:41:50 2002
@@ -828,12 +828,13 @@
def add(self, name, cnf={}, **kw):
apply(self.tk.call,
(self._w, 'add', name) +
self._options(cnf, kw))
- self.subwidget_list[name] =
TixSubWidget(self, name)
+ self.subwidget_list[name] =
TixSubWidget(self, name, destroy_physically
return self.subwidget_list[name]
def delete(self, name):
+ del self.subwidget_list[name]
self.tk.call(self._w, 'delete', name)
-
+
def page(self, name):
return self.subwidget(name)
Tix.py Version
# $Id: Tix.py,v 1.4 2001/10/09 11:50:55 loewis Exp $
Tix Version
tix-8.1.3
Tcl/Tk-version
tcl8.3-8.3.3
tk8.3_8.3.3
----------------------------------------------------------------------
Comment By: Martin v. Löwis (loewis)
Date: 2002-03-27 19:05
Message:
Logged In: YES
user_id=21627
This is fixed in Tix.py 1.8. Notice that setting
destroy_physically is not the right thing: that way, the Tcl
widget won't be destroyed at all.
Instead, the problem was that the line
self.subwidget_list[name] = TixSubWidget(self, name)
would first create the new subwidget, then remove the last
reference to the old subwidget. The __del__ of the old
subwidget would then destroy the Tcl widget. Since the old
widget and the new widget have the same name, this would
delete the new widget. The solution is to explicitly destroy
the subwidget in delete.
----------------------------------------------------------------------
Comment By: Christoph Monzel (chris_mo)
Date: 2002-02-13 00:31
Message:
Logged In: YES
user_id=456854
Okay, this is my first bug report, and seems not a good
idea to paste patches into the text window :(
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=516703&group_id=5470