I have a project which uses the PositionToXY method
of wxTextCtrl. In version 2.3.2.1, this method appears
to return a tuple of 3 integers, even though the
documentation still says it should return two integers (x and y).
The method did in fact return 2 integers in 2.2.1 and even in 2.3.1.
Is this a deliberate or inadvertant change?
I'm using:
Win98SE
Python 1.5.2
wxPython 2.3.2.1 (hybrid) [was using 2.3.1 hybrid, and before that
2.2.1]
I have a project which uses the PositionToXY method
of wxTextCtrl. In version 2.3.2.1, this method appears
to return a tuple of 3 integers, even though the
documentation still says it should return two integers (x and y).
The method did in fact return 2 integers in 2.2.1 and even in 2.3.1.
Is this a deliberate or inadvertant change?
Inadvertant. The three values are (success, x, y) where success is the
return value of the C++ method.
Should I change it back or do people like getting the success code there?
···
--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters? http://wxPython.org Relax with wxPython!
I have a project which uses the PositionToXY method
of wxTextCtrl. In version 2.3.2.1, this method appears
to return a tuple of 3 integers, even though the
documentation still says it should return two integers (x and y).
The method did in fact return 2 integers in 2.2.1 and even in 2.3.1.
Is this a deliberate or inadvertant change?
Inadvertant. The three values are (success, x, y) where success is the
return value of the C++ method.
Should I change it back or do people like getting the success code there?
--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters? http://wxPython.org Relax with wxPython!
I have a bunch of code which uses the old (and documented) interface, so changing it back would be better for me, especially since not all my users will necessarily upgrade to the latest version of wxPython
What did the old version return on failure? Returning None to indicate failure would seem to make sense.
> I have a project which uses the PositionToXY method
> of wxTextCtrl. In version 2.3.2.1, this method appears
> to return a tuple of 3 integers, even though the
> documentation still says it should return two integers (x and y).
> The method did in fact return 2 integers in 2.2.1 and even in 2.3.1.
>
> Is this a deliberate or inadvertant change?
Inadvertant. The three values are (success, x, y) where success is the
return value of the C++ method.
Should I change it back or do people like getting the success code there?
This broke one of the PythonCard samples too. Is this a wxWindows API change
or just wxPython? If wxWindows, then leave it, if wxPython I would say use
the old way. For now I've changed the wrapper code to check the len of the
returned tuple so it can handle both formats.
I looked at controls.py and all I see is
def PositionToXY(self, *_args, **_kwargs):
val = apply(controlsc.wxTextCtrl_PositionToXY,(self,) + _args,
_kwargs)
return val
The source is the ultimate documentation definitely needs to change; I know,
I supposed to go look at the C++ sources. Is there anything people on the
list can do to help speed up auto-generating docs from the sources, getting
SWIG to supply something more meaningful than what we see above...
I have a bunch of code which uses the old (and documented) interface, so
changing it back would be better for me, especially since not all my
users will necessarily upgrade to the latest version of wxPython
Okay, that makes sense. I'll change it to someting compatible with the old
way.
What did the old version return on failure? Returning None to indicate
failure would seem to make sense.
I think it probably took the easy way out and just ignored it. Any votes on
returning None vs. raising an exception?
···
--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters? http://wxPython.org Relax with wxPython!
> This broke one of the PythonCard samples too. Is this a wxWindows API
change
> or just wxPython? If wxWindows, then leave it, if wxPython I
would say use
> the old way.
The wx API was always this way, I think wxPython just ignored the return
value before.
The docs say
"TRUE on success, FALSE on failure (most likely due to a too large position
parameter)."
and of course your note
"wxPython note: In Python, PositionToXY() returns a tuple containing the x
and y values, so (x,y) = PositionToXY() is equivalent to the call described
above."
It is important to be consistent, so what are you doing for other wxWindows
methods that return TRUE on success, FALSE on failure? If you've been
throwing exceptions, then PositionToXY should probably throw an exception.
Returning None doesn't sound right, are you doing that anywhere else?
Raise an exception would be my preference. Otherwise doing:
x,y = y.PostionToXY( position )
Is going to return a ValueError instead of something useful. Although I suppose returning -1,-1 might work just as well for avoiding that, but it would still require an explicit check. Not really sure how "exceptional" the failure would be, guess that's up to you .
My 0.02,
Mike
Robin Dunn wrote:
···
I have a bunch of code which uses the old (and documented) interface, so
changing it back would be better for me, especially since not all my
users will necessarily upgrade to the latest version of wxPython
Okay, that makes sense. I'll change it to someting compatible with the old
way.
What did the old version return on failure? Returning None to indicate
failure would seem to make sense.
I think it probably took the easy way out and just ignored it. Any votes on
returning None vs. raising an exception?
--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters? http://wxPython.org Relax with wxPython!