In Python 3.10, a change[1] was implemented where extension functions
that take integer arguments will no longer silently accept non-integer
arguments (e.g., floats) that can only be converted to integers with a
loss of precision. This PR fixes most of these issues in the pure-Python
classes and demos by explicitly converting the parameters to int before
passing them to wxWidgets. There is loss of precision, but this was
happening before (automatically) anyway as most wxWidgets DeviceContext
functions operate using integers.
Additionally, the PR fixes a few sizing issues, mostly with SpinCtrls being
too small on GTK3.
This is an example of the relevant exception:
Traceback (most recent call last):
File "/usr/lib64/python3.10/site-packages/wx/lib/agw/pygauge.py", line 355, in OnPaint
r.width = w
TypeError: 'float' object cannot be interpreted as an integer
Fixes#2038.
[1] https://bugs.python.org/issue37999
Fixes Python 3.10 and should be faster not having to download & install
Python and pip.
This also removes Python 3.6 from macOS CI - the Azure hosted version of
Python 3.6 has a problem with linker flags (it is setting -stack_size) and
can't compile Python extensions. Python 3.6 is going to be EOL in a month or
so, so it seems fine to just remove it from CI.
When binding events to multiple methods and then unbinding them later,
in the same order they were bound, the wrong method would get unbound.
For example:
self.btn.Bind(wx.EVT_BUTTON, self.onButton1)
self.btn.Bind(wx.EVT_BUTTON, self.onButton1)
followed by:
self.btn.Unbind(wx.EVT_BUTTON, handler=self.onButton2)
self.btn.Unbind(wx.EVT_BUTTON, handler=self.onButton1)
works, but the reverse fails:
self.btn.Unbind(wx.EVT_BUTTON, handler=self.onButton1)
self.btn.Unbind(wx.EVT_BUTTON, handler=self.onButton2)
The reason is that the wxPython Disconnect() method called the wxWidgets
Disconnect() method with the userData parameter set to NULL. In this
case, wxWidgets performs no filtering based on the userData parameter
and this could result in the wrong handler getting disconnected.
Fix this by setting the userData to a known value before calling
wxWidgets Disconnect() method so that it will disconnect the correct
handler.
This commit also adds a test that verifies the fix.
Fixes#2027.
Add the keyword 'finally' in Execute, to fix miss-indentation
when pasting the following code:
try:
1
finally: <-- indent error
0
Add the keyword 'with' to fix mis-indentation when typing:
with xxx:
| <-- incorrect auto-indentation in the next line