You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Operating system: Ubuntu 20.04, Windows 10 wxPython version & source: 4.2.1 Python version & source: 3.8.10 (Ubuntu), 3.10.0 (Windows) Description of the problem:
InformFirstDirection() must be overridden by classes that derive from Sizer in order to properly implement any non-trivial sizer, as indicated by this comment:
However, wxPython forbids this method from being overridden in Python classes that derive from Sizer. The only methods that can be overridden are CalcMin() and RepositionChildren():
Remove all virtuals except for CalcMin and RecalcSizes.
"""
removeVirtuals(klass)
klass.find('CalcMin').isVirtual=True
klass.find('RepositionChildren').isVirtual=True
This means it is not possible to implement a non-trivial custom Sizer in Python. Even the simple BoxSizer and WrapSizer need InformFirstDirection() to properly calculate their size.
I am trying to implement a custom Sizer in Python similar to WrapSizer that uses a box packing algorithm to more efficiently layout its children. Unfortunately, without this method being virtual, it is impossible to make it work properly.
(As a workaround I am having my custom sizer store a reference to its containing ScrolledPanel so it can call GetClientSize() on it during its CalcMin(). This is an ugly hack that should not be necessary.)
The text was updated successfully, but these errors were encountered:
swt2c
added a commit
to swt2c/Phoenix
that referenced
this issue
Aug 29, 2023
Operating system: Ubuntu 20.04, Windows 10
wxPython version & source: 4.2.1
Python version & source: 3.8.10 (Ubuntu), 3.10.0 (Windows)
Description of the problem:
InformFirstDirection()
must be overridden by classes that derive from Sizer in order to properly implement any non-trivial sizer, as indicated by this comment:https://github.com/wxWidgets/wxWidgets/blob/be772c284f20969e7c2a5b62d3d43db56cdc5a6b/include/wx/sizer.h#L636-L642
However, wxPython forbids this method from being overridden in Python classes that derive from Sizer. The only methods that can be overridden are
CalcMin()
andRepositionChildren()
:Phoenix/etgtools/tweaker_tools.py
Lines 327 to 333 in e4fd9a3
This means it is not possible to implement a non-trivial custom Sizer in Python. Even the simple BoxSizer and WrapSizer need
InformFirstDirection()
to properly calculate their size.I am trying to implement a custom Sizer in Python similar to WrapSizer that uses a box packing algorithm to more efficiently layout its children. Unfortunately, without this method being virtual, it is impossible to make it work properly.
(As a workaround I am having my custom sizer store a reference to its containing ScrolledPanel so it can call
GetClientSize()
on it during itsCalcMin()
. This is an ugly hack that should not be necessary.)The text was updated successfully, but these errors were encountered: