New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TextCtrl changes size in Design window when a border or alignment is set. #536
Comments
On Windows I can see only a small increase in size. |
The size in the preview window never changes, only the design window. That is one workaround that I have used, i.e. keep pressing F5 to refresh the preview window to see how the layout really looks. However, when working on a large design it becomes a bit clumsy when the design and preview windows keep obstructing each other. |
OK, thanks, I will check in my Linux VM. |
I can see it on Linux with 4.2.1. It was OK with 4.1.x. |
Between these releases there were some changes in the TextCtrl code for gtk. That makes it harder for me to debug. I prefer Windows problems... |
Building wxPython on Linux is still a nightmare. The root cause is this line in wxWidgets 3.2.1 [src/gtk/textctrl.cpp]: The relevant code in the wxWidgets versions: wxWidgets 3.1.0
wxWidgets 3.2.1:
current
|
I don't see how to call GTKGetEntryMargins or GTKGetPreferredSize from Python. So I can't replace this code with some Python code as workaround. The only (untested) workaround I'm seeing is this one in edit_sizers/edit_sizers.py: The comment is out of date, as wxGlade does now re-create TextCtrl on style change. Still, I would like to leave the SetSize() call there. |
Could you please test this workaround whether it's working for you? |
I edited edit_sizers.py as shown in the png of the diff you posted. I then tested the following cases starting from a fresh design in each case:
It looks like the code change only prevents the resizing for the first action in setting a border or alignment. However, the resizing is still happening for the other changes. |
OK, next try. I have created a separate branch ISSUE_536 for this. |
I have tested the code from the ISSUE_536 branch and the workaround is working for me also. Thank you for investigating this problem and devising the workaround. |
When you open this .wxg file, can you navigate in the Design window using the arrow keys? |
Which .wxg file do you mean? |
The one from your screenshot above. Frame -> Panel -> Sizer -> TextCtrl |
I get the same. The arrow keys navigate in the Tree window, but not in the Design window. |
OK. This is not critical, but anyway I will look for a solution. |
OS: Linux Mint 21.2
wxPython: wxPython 4.2.1 gtk3 (phoenix) wxWidgets 3.2.2.1
Python: 3.10.12
wxGlade: 1.0.5 and 1.1.0a2
If I add a TextCtrl to a BoxSizer or a FlexGridSizer and then check one of the Border options or one of the Alignment options (excluding wxEXPAND) in the TextCtrl's Layout tab, the TextCtrl increases in size in the Design window. If I save the .wxg file and then re-open it, the size of the TextCtrl reverts to its original default size.
Simple example:
If I repeat the above steps but check wxALIGN_RIGHT instead of checking one of the Border options, then the TextCtrl's size gets set to 93,49.
Unchecking the Border or Alignment option can cause the TextCtrl's height increase further.
I have also noticed that if I check the Size option of a TextCtrl and explicitly set it to a value such as 100,-1 then the size displayed in the Design window still increases, although it is still showing as 100,-1 in the Common tab.
Other composite controls that contain a TextCtrl, such as ComboBox, SpinCtrl and DatePickerCtrl do not display the same issue.
I first noticed this issue when I was placing TextCtrls in a FlexGridSizer and was trying to set all the controls in a row to wxALIGN_CENTER_VERTICAL to line them up in particular way. Because the TextCtrls kept changing size, I had to keep saving and loading the project to see if the controls were lined up correctly.
The text was updated successfully, but these errors were encountered: