Hello,
That sounds suspiciously like a bug that Dan found in Python 2.6, so maybe
it's also there in 2.5?? I've attached a fix for 2.6. To apply it cd
into /usr/lib/python2.5/lib-tk/ and do:
patch < broken2.6_tkinter_patch.diff
Well, backup the existing Tkinter.py just to be safe. And then do a diff
on the old and the new after doing the patch. When I did a diff on the
2.6 Tkinter.py I got the result at the bottom. If you have a lot more
diffs than that then it's possible (likely) this patch won't work in 2.5
(although a hand edit might work).
Wayne
diff Tkinter.py.orig Tkinter.py
1923a1924,1925
> if self._tclCommands is None:
> self._tclCommands = []
2661c2663
< """Delete menu items between INDEX1 and INDEX2 (not
included)."""
---
> """Delete menu items between INDEX1 and INDEX2 (included)."""
2664,2671c2666,2675
< cmds = []
< (num_index1, num_index2) = (self.index(index1),
self.index(index2))
< if (num_index1 is not None) and (num_index2 is not None):
< for i in range(num_index1, num_index2 + 1):
< if 'command' in self.entryconfig(i):
< c = str(self.entrycget(i, 'command'))
< if c in self._tclCommands:
< cmds.append(c)
---
>
> num_index1, num_index2 = self.index(index1), self.index(index2)
> if (num_index1 is None) or (num_index2 is None):
> num_index1, num_index2 = 0, -1
>
> for i in range(num_index1, num_index2 + 1):
> if 'command' in self.entryconfig(i):
> c = str(self.entrycget(i, 'command'))
> if c:
> self.deletecommand(c)
2673,2674d2676
< for c in cmds:
< self.deletecommand(c)
On Fri, 7 Nov 2008, Magnus Lundborg wrote:
> Hello,
>
> Recently I've started encountering errors like this a lot:
>
> >>> Exception in Tkinter callback
> Traceback (most recent call last):
> File "/usr/lib/python2.5/lib-tk/Tkinter.py", line 1417, in __call__
> return self.func(*args)
> File
> "/home/magnusl/CCPN/ccpnmr/ccpnmr2.0/python/ccpnmr/analysis/AnalysisPopup.py",
> line 1158, in openProject
> help_url=determineHelpUrl(OpenProjectPopup))
> File
> "/home/magnusl/CCPN/ccpnmr/ccpnmr2.0/python/ccpnmr/analysis/AnalysisPopup.py",
> line 1143, in openPopup
> transient=transient, *args, **kw)
> File
> "/home/magnusl/CCPN/ccpnmr/ccpnmr2.0/python/memops/editor/OpenProjectPopup.py",
> line 93, in __init__
> BasePopup.__init__(self, parent=parent, title=title, *args, **kw)
> File
> "/home/magnusl/CCPN/ccpnmr/temporaryReleaseDir/ccpnmr/ccpnmr2.0/python/memops/editor/BasePopup.py",
> line 85, in __init__
> File
> "/home/magnusl/CCPN/ccpnmr/temporaryReleaseDir/ccpnmr/ccpnmr2.0/python/memops/gui/BasePopup.py",
> line 124, in __init__
> File
> "/home/magnusl/CCPN/ccpnmr/ccpnmr2.0/python/memops/editor/OpenProjectPopup.py",
> line 105, in body
> extraHeadings=('Status',), extraJustifies=('left',))
> File
> "/home/magnusl/CCPN/ccpnmr/temporaryReleaseDir/ccpnmr/ccpnmr2.0/python/memops/gui/FileSelect.py",
> line 224, in __init__
> File
> "/home/magnusl/CCPN/ccpnmr/temporaryReleaseDir/ccpnmr/ccpnmr2.0/python/memops/gui/FileSelect.py",
> line 414, in updateFileList
> File
> "/home/magnusl/CCPN/ccpnmr/ccpnmr2.0/python/memops/gui/ScrolledMatrix.py",
> line 1921, in update
> self.setGraphMenu()
> File
> "/home/magnusl/CCPN/ccpnmr/ccpnmr2.0/python/memops/gui/ScrolledMatrix.py",
> line 434, in setGraphMenu
> options = self.getGraphMenuOptions()
> File
> "/home/magnusl/CCPN/ccpnmr/ccpnmr2.0/python/memops/gui/ScrolledMatrix.py",
> line 484, in getGraphMenuOptions
> submenu.setMenuItems(items)
> File
> "/home/magnusl/CCPN/ccpnmr/temporaryReleaseDir/ccpnmr/ccpnmr2.0/python/memops/gui/Menu.py",
> line 114, in setMenuItems
> File
> "/home/magnusl/CCPN/ccpnmr/temporaryReleaseDir/ccpnmr/ccpnmr2.0/python/memops/gui/Menu.py",
> line 127, in deleteMenuItems
> File "/usr/lib/python2.5/lib-tk/Tkinter.py", line 2683, in delete
> if c in self._tclCommands:
> TypeError: argument of type 'NoneType' is not iterable
>
>
> This one comes when I try to open the Open Project window and then I
> cannot do anything from that window. I get a similar error when opening
> some other windows.
>
> I have just noticed these errors recently, but I am not sure if it is
> anything that is wrong in the CCPN code or if it has to do with a
> reasonably recent system update.
>
> Best Regards
> /Magnus
>
> --
> Magnus Lundborg, ph.D. Student
> Stockholm University
> Department of Organic Chemistry
> Arrhenius Laboratory
> S-106 91 Stockholm
> Sweden
> E-mail address: [log in to unmask]
>
Index: Lib/lib-tk/Tkinter.py
===================================================================
--- Lib/lib-tk/Tkinter.py (revision 66230)
+++ Lib/lib-tk/Tkinter.py (working copy)
@@ -1921,6 +1921,8 @@
cnf = _cnfmerge((cnf, kw))
self.widgetName = widgetName
BaseWidget._setup(self, master, cnf)
+ if self._tclCommands is None:
+ self._tclCommands = []
classes = []
for k in cnf.keys():
if type(k) is ClassType:
@@ -2658,20 +2660,20 @@
"""Add separator at INDEX."""
self.insert(index, 'separator', cnf or kw)
def delete(self, index1, index2=None):
- """Delete menu items between INDEX1 and INDEX2 (not included)."""
+ """Delete menu items between INDEX1 and INDEX2 (included)."""
if index2 is None:
index2 = index1
- cmds = []
- (num_index1, num_index2) = (self.index(index1), self.index(index2))
- if (num_index1 is not None) and (num_index2 is not None):
- for i in range(num_index1, num_index2 + 1):
- if 'command' in self.entryconfig(i):
- c = str(self.entrycget(i, 'command'))
- if c in self._tclCommands:
- cmds.append(c)
+
+ num_index1, num_index2 = self.index(index1), self.index(index2)
+ if (num_index1 is None) or (num_index2 is None):
+ num_index1, num_index2 = 0, -1
+
+ for i in range(num_index1, num_index2 + 1):
+ if 'command' in self.entryconfig(i):
+ c = str(self.entrycget(i, 'command'))
+ if c:
+ self.deletecommand(c)
self.tk.call(self._w, 'delete', index1, index2)
- for c in cmds:
- self.deletecommand(c)
def entrycget(self, index, option):
"""Return the resource value of an menu item for OPTION at INDEX."""
return self.tk.call(self._w, 'entrycget', index, '-' + option)
|