Phoenix icon indicating copy to clipboard operation
Phoenix copied to clipboard

MacOS: TextCtrl lacks default size on 4.2.x

Open briantoby opened this issue 2 years ago • 4 comments

MacOS 10.15.7 wx 4.2.1a1.dev5539+906adf71 installed with pip from https://wxpython.org/Phoenix/snapshot-builds/ Python 3.10.6 installed with Miniforge3-22.9.0-2-MacOSX-x86_64.sh from conda-forgePython

At least under some conditions wx.TextCtrl does not get a default size with wxpython 4.2.0 and 4.2.1dev. This has been seen so far only on the Mac and does not appear to happen on Windows. This can be demonstrated using the wxdemo RadioButton demo, where exactly the same code (the 4.1 wxdemo code) was run with two different python installations (but note that pythonw is not needed in 4.2 -- yay!)

Screen image with wx4.2: wx42-RadioButton

Screen image with wx4.2: wx41-RadioButton

Invocation details (click to expand)
(base) toby@BHT20 demo % python "/Users/toby/Library/Application Support/wxPython/wxPython-demo-4.1.1/demo/RadioButton.py" 
Python 3.10.6 | packaged by conda-forge | (main, Aug 22 2022, 20:41:54) [Clang 13.0.1 ]
wx.version: 4.2.1a1.dev5539+906adf71 osx-cocoa (phoenix) wxWidgets 3.2.1

(base) toby@BHT20 demo % pythonw "/Users/toby/Library/Application Support/wxPython/wxPython-demo-4.1.1/demo/RadioButton.py"
Python 3.9.1 (default, Dec 11 2020, 06:28:49) 
[Clang 10.0.0 ]
wx.version: 4.1.1 osx-cocoa (phoenix) wxWidgets 3.1.5

briantoby avatar Dec 10 '22 15:12 briantoby

@briantoby I can confirm that I see this too on MacOS.

With wxPython 4.2 and source build using the current branch, it seems the default size for a wxTextCtrl is (21, 24). With wxPython 4.1.1 (using the PyPI wheel for Python 3.9) it is (105, 22). I would not say that either of these is obviously a more correct default, but stability should count for something ;).

I have not investigated where this change comes from.

newville avatar Dec 10 '22 18:12 newville

Also, wxTextCtrl.DoGetBestSize is not called during initialization. It is called only if InvalidateBestSize() is called. This problem might be related.

2pirko avatar Jan 08 '24 14:01 2pirko

There were several changes to wxTextCtrl::DoGetSizeFromTextSize for gtk. See here for a summary: https://github.com/wxGlade/wxGlade/issues/536#issuecomment-1861686257 3.2.1 / 4.2.1 is certainly broken.

DietmarSchwertberger avatar Jan 08 '24 16:01 DietmarSchwertberger

This issue has been mentioned on Discuss wxPython. There might be relevant details there:

https://discuss.wxpython.org/t/textctrl-in-4-2-1-smaller-than-in-4-2-0/36625/8

RobinD42 avatar Jan 10 '24 14:01 RobinD42