I'm trying to add control points to LineShape. But if my LineShape has more than 2 control points my program fails with following message:
···
=====================
Traceback (most recent call last):
File "D:\Kids\Aka\Python\my\PyVNB\test\ogl\myogl.py", line 40, in ?
canvas = Canvas(frame, frame)
File "D:\Kids\Aka\Python\my\PyVNB\test\ogl\myogl.py", line 30, in __init__
self.shapes[i].AddLine(line, self.shapes[i + 1])
File "E:\PROGRA~2\python\Lib\site-packages\wx\lib\ogl\_basic.py", line 1250, i
n AddLine
self.MoveLinks(dc)
File "E:\PROGRA~2\python\Lib\site-packages\wx\lib\ogl\_basic.py", line 1129, i
n MoveLinks
self.GetEventHandler().OnMoveLinks(dc)
File "E:\PROGRA~2\python\Lib\site-packages\wx\lib\ogl\_basic.py", line 726, in
OnMoveLinks
line.GetEventHandler().OnMoveLink(dc)
File "E:\PROGRA~2\python\lib\site-packages\wx\lib\ogl\_lines.py", line 917, in
OnMoveLink
end_x, end_y, other_end_x, other_end_y = self.FindLineEndPoints()
TypeError: unpack non-sequence
I had dig in _lines.py and i think i find the solution.
This is cutted a part of FindLineEndPoints() finction:
=====================
if len(self._lineControlPoints) > 2:
# SOMETHING WHAT SETS end_x, end_y, other_end_x, other_end_y
else:
# ANOTHER WHAT SETS end_x, end_y, other_end_x, other_end_y
return end_x, end_y, other_end_x, other_end_y
Note, that return placed in the else part, and no return in first block.
I think this return must be placed after if statement, e.g. it must be unindented. When i unindent this line in my _lines.py, my program works well.
It is a bug or feature?? May be i must read docs more carefully.
> I'm trying to add control points to LineShape. But if my LineShape has
> more than 2 control points my program fails with following message:
> =====================
> Traceback (most recent call last):
> File "D:\Kids\Aka\Python\my\PyVNB\test\ogl\myogl.py", line 40, in ?
> canvas = Canvas(frame, frame)
> File "D:\Kids\Aka\Python\my\PyVNB\test\ogl\myogl.py", line 30, in
> __init__
> self.shapes[i].AddLine(line, self.shapes[i + 1])
> File "E:\PROGRA~2\python\Lib\site-packages\wx\lib\ogl\_basic.py", line
> 1250, i
> n AddLine
> self.MoveLinks(dc)
> File "E:\PROGRA~2\python\Lib\site-packages\wx\lib\ogl\_basic.py", line
> 1129, i
> n MoveLinks
> self.GetEventHandler().OnMoveLinks(dc)
> File "E:\PROGRA~2\python\Lib\site-packages\wx\lib\ogl\_basic.py", line
> 726, in
> OnMoveLinks
> line.GetEventHandler().OnMoveLink(dc)
> File "E:\PROGRA~2\python\lib\site-packages\wx\lib\ogl\_lines.py", line
> 917, in
> OnMoveLink
> end_x, end_y, other_end_x, other_end_y = self.FindLineEndPoints()
> TypeError: unpack non-sequence
> =====================
>
>
> I had dig in _lines.py and i think i find the solution.
> This is cutted a part of FindLineEndPoints() finction:
>
> =====================
> if len(self._lineControlPoints) > 2:
> # SOMETHING WHAT SETS end_x, end_y, other_end_x, other_end_y
> else:
> # ANOTHER WHAT SETS end_x, end_y, other_end_x, other_end_y
>
> return end_x, end_y, other_end_x, other_end_y
> =====================
>
> Note, that return placed in the else part, and no return in first block.
> I think this return must be placed after if statement, e.g. it must be
> unindented. When i unindent this line in my _lines.py, my program works
> well.
>
> It is a bug or feature?? May be i must read docs more carefully.
>
Too bad you didn't say which version of wxPython this was under, but I
do believe this is fixed in the latest versions. But I'll check on it
anyway.
Oh, sorry. I'm forgot. I have latest version of wxPython: wxPythonWIN32-2.5.2.8u-Py23. I'd downloaded it from wxpython.org on this week.
···
"Ilya Skriblovsky" <ily@school91.nnov.ru> writes:
> I'm trying to add control points to LineShape. But if my LineShape has
> more than 2 control points my program fails with following message:
> =====================
> Traceback (most recent call last):
> File "D:\Kids\Aka\Python\my\PyVNB\test\ogl\myogl.py", line 40, in ?
> canvas = Canvas(frame, frame)
> File "D:\Kids\Aka\Python\my\PyVNB\test\ogl\myogl.py", line 30, in
> __init__
> self.shapes[i].AddLine(line, self.shapes[i + 1])
> File "E:\PROGRA~2\python\Lib\site-packages\wx\lib\ogl\_basic.py", line
> 1250, i
> n AddLine
> self.MoveLinks(dc)
> File "E:\PROGRA~2\python\Lib\site-packages\wx\lib\ogl\_basic.py", line
> 1129, i
> n MoveLinks
> self.GetEventHandler().OnMoveLinks(dc)
> File "E:\PROGRA~2\python\Lib\site-packages\wx\lib\ogl\_basic.py", line
> 726, in
> OnMoveLinks
> line.GetEventHandler().OnMoveLink(dc)
> File "E:\PROGRA~2\python\lib\site-packages\wx\lib\ogl\_lines.py", line
> 917, in
> OnMoveLink
> end_x, end_y, other_end_x, other_end_y = self.FindLineEndPoints()
> TypeError: unpack non-sequence
> =====================
>
> I had dig in _lines.py and i think i find the solution.
> This is cutted a part of FindLineEndPoints() finction:
>
> =====================
> if len(self._lineControlPoints) > 2:
> # SOMETHING WHAT SETS end_x, end_y, other_end_x, other_end_y
> else:
> # ANOTHER WHAT SETS end_x, end_y, other_end_x, other_end_y
>
> return end_x, end_y, other_end_x, other_end_y
> =====================
>
> Note, that return placed in the else part, and no return in first block.
> I think this return must be placed after if statement, e.g. it must be
> unindented. When i unindent this line in my _lines.py, my program works
> well.
>
> It is a bug or feature?? May be i must read docs more carefully.
>
Too bad you didn't say which version of wxPython this was under, but I
do believe this is fixed in the latest versions. But I'll check on it
anyway.
Note, that return placed in the else part, and no return in first block.
I think this return must be placed after if statement, e.g. it must be unindented. When i unindent this line in my _lines.py, my program works well.
This has already been fixed in CVS.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!