I’ll probably have a number of tips for anyone updating 2.8 code to work with Phoenix, but one of the more pressing ones concerns getting tuples for various size/position methods like:
GetMinSizeTuple
GetPositionTuple
GetBestSizeTuple
GetClientSizeTuple
GetScreenPositionTuple
GetSizeTuple
The proper way to convert for what I think is identical behavior is
GetMinSizeTuple() -> GetMinSize().Get()
GetPositionTuple() -> GetPosition().Get()
GetBestSizeTuple() -> GetBestSize().Get()
GetClientSizeTuple() -> GetClientSize().Get()
GetScreenPositionTuple() -> GetScreenPosition() .Get()
GetSizeTuple() -> GetSize() .Get()
Without the “.Get()”, the returned value is a wx object.
Cheers, Eric
I'll probably have a number of tips for anyone updating 2.8 code to work
with Phoenix, but one of the more pressing ones concerns getting tuples for
various size/position methods like:
GetMinSizeTuple
GetPositionTuple
GetBestSizeTuple
GetClientSizeTuple
GetScreenPositionTuple
GetSizeTuple
The proper way to convert for what I think is identical behavior is
GetMinSizeTuple() -> GetMinSize().Get()
GetPositionTuple() -> GetPosition().Get()
GetBestSizeTuple() -> GetBestSize().Get()
GetClientSizeTuple() -> GetClientSize().Get()
GetScreenPositionTuple() -> GetScreenPosition() .Get()
GetSizeTuple() -> GetSize() .Get()
Without the ".Get()", the returned value is a wx object.
Cheers, Eric
You may find https://www.wxpython.org/Phoenix/docs/html/classic_vs_phoeni
x.html helpful. With this (and the otherwise excellent documentation), I
found the transition remarkably easy. I do have some tests for Phoenix (as
is_wxPhoenix = 'phoenix' in wx.PlatformInfo) in some places to support both
versions.
For example, this handy part of the migration guide does mention that
GetSizeTuple() has been replaced by wx.GetSize(), which returns a wx.Size()
object. But, you don't *need* to use GetSize().Get(), as you can use:
width, height = window.GetSize()
That is, a wx.Size object can be used as a two-element sequence. Or you
can use the height and width attributes. Or you can use the Get() method.
--Matt
···
On Sun, Apr 2, 2017 at 7:12 AM, <braidedlogix@gmail.com> wrote:
When I test this out in PyCrust, the h,w=whatever.GetSize() works very well. On the other hand, this has been a consistent point of failure in the traitsui codes I’ve tried to get working. The error message is usually something like “too many values to unpack”. Using the Get() method eliminates these errors and pushes the failure points farther downstream.
There are many contexts where previous codes did not use an explicit h,w=…Tuple(), but the outcomes expected tuple results. On the whole, I would stick with my tip to guarantee consistency with previous outcomes.
On the whole, this is very interesting for me, because it makes me wonder what’s happening in the sequence of execution to prevent the proper assignment overload. I have one inexplicable segfault failure on a window.SetSize(a,b,c,d) .
The link you mention is really excellent, and I developed a script that will automatically make some of the drop-in substitutions. Anyone venturing down this pathway should also carefully read the stuff in
https://wxpython.org/Phoenix/docs/html/MigrationGuide.html