When opening a file, I get (in windows) the error message:
Traceback (most recent call last):
File "F:\nj2007\python\drpython\drpython.py", line 2186, in OnOpen
self.OpenFile(filenames, False, encoding=theencoding)
File "F:\nj2007\python\drpython\drpython.py", line 2985, in OpenFile
File "F:\nj2007\python\drpython\drpython.py", line 3034, in reloaddocumentsmenu
File "E:\Python25\lib\site-packages\wx-2.8-msw-unicode\wx\_core.py", line 10821, in __getitem__
return _core_.MenuItemList___getitem__(*args, **kwargs)
IndexError: sequence index out of range
I have solved it by the next fix:
in file 'drpython.py'
the lines with the numbers 3030 and so on are replaced by the next lines:
# x = 0
# while x < num:
x = num-1
while x >= 0:
# x = x + 1
x -= 1
I suspect, this happens only with this new wxPython Version on Windows.
That Bug was already reported:
I think, it resembles your fix. You could get also the last version (from svn), there should be also the fix in there. But nevertheless, cool that you find (your) fix yourself too.
Yes, apparently this is the same bug fixed in r267. Indexing seems not to work correctly in newer wx versions.
The problem is that this is a common pattern in drPython:
num = len(mnuitems)
x = 0
while x < num:
x = x + 1
I think it should be replaced for a more pythonic loop (as in r267):
for mnuitem in mnuitems:
There is some reason to do the first unpithonic loop?
Sometimes removing or adding items inside a for loop causes undefined behaviour, but this doesn't seem to be the case.
I don't think, theres a reason for that. Of course, your pythonic way is far more better. Maybe it was a coding style in the first phases of Drpython, who knows. ;) Would you like to check in this?
this loop is also in def setupdocumentsmenu.
BTW: If I update DrPython, I have still r261.
Sorry, I mean r257
I hadn't so much time last weeks, but I hope I could review that in this weekend.
Thank you for the reponses.
for mnuitem in mnuitems:
has the folowing complication:
the statement "self.documentsmenu.Remove(mnuitem.GetId())" change "mnuitems"
So the codition in the for-statement is changed.
My advice is: don't use such tricky constructions.
"You could get also the last version (from svn)"
I don't no how to get the last version.
Please explain me in more detail.
About for condition, yes, as I stated in previous post, changing a list inside a loop is not a good practice, but it doesn't seems to be a problem here:
menuitems (id): [810,-2,1098,-2,6061,6062,-2,8001,8000]
Here, mnuitems is not just a list, is a <class 'wx._core.MenuItemList'>, that may be handling this things correctly.
Anyway, I prefer a pythonic solution (if it doesn't cause any troubles, of course), but if you prefer another, less-pythonic solution, that's fine for me :-)
You need an svn client and then checkout. rapidsvn, esvn (both for linux and windows). I personally use on windows tortoise svn, (a context menu in filemanager (explorer or total commander), and I find it very comfortable.
The first time, you do a checkout and type in:
https://drpython.svn.sourceforge.net/svnroot/drpython and specify a target directory.
If you are more interested, I could add you as member and give you a write access to svn.
BTW: As I said, the code is very old and not from me. ;)
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.