Hello!
It’s my almost first time trying to use wxpython and have something really strange and can’t find any reason for that. I save and restore window geometry using wx.lib.agw.persist.PersistenceManager and each next run makes window’s height more than was saved to config file. I noticed that as I set window size using SetSize, window recieves EVT_SIZE with actual size bigger that was set. But if I manually save and restore window size using SetClientSize instead of PersistanceManager and SetSize everything goes fine. Does anyone have an idea how to fix this issue? Is there any workaround? Problem happends using 4.2.0 gtk3 (phoenix) wxWidgets 3.2.2 under Ubuntu 23.04 with Gnome.
My minimal code which reproduces this behavior:
Thank you!
I’d like to get the same result. But when I clear Persist.conf and run this code I get the following result. Note that I don’t change window size manually. I just run it and close window.
However, what’s even weirder, is that when I step through the code in PyCharm’s debugger, it does output three lines, with a similar incorrect size values!
switched to ubuntu-wayland and everything goes fine with my first code example. Persistance works as it shood. But the second example gives my the following (argh!) output:
If I modify the OnSize() method in your second example to call event.Skip() as shown below, then I no longer get the third call with the wrong sizes, even when running in debug.
Moreover, I created a simple C++ application with wxWidgets 3.2.2-Linux-Unicode build and it has the same problem. The Qt script doesn’t have it. I hope today or tomorrow I will have some time to try this with pygobject or gtkmm (I’m not familiar with it so it requires more time).
Thank you for your time!
pygobject with gtk-3 and gtk-4 produced only one event with correct size.
But… Here we are!
Am I right that this is even more weird now?
Window is created with height 200. Then window manager adds title and it is included into window height.
When window is closed it’s height is 237 and this value is saved to config. When application starts again it read 237 from config, window manager add title… (Groundhog Day).
But why?
I added print(f'client size: {self.GetClientSize()}') to OnSize and now output is:
Looks like window geometry is restored too early and adding title to window after that causes problem. Maybe your window manager produces different event queue and that’s why we get different results.
Thank you. I don’t know why but it looks like in my case window is created without decorations. And it’s geometry should be restored after receiving decorations. Looks like soon it will be popular question I wonder if there is a way to determine that window has received it’s final size and is ready to be actually shown on screen? As we see in my code the first call of OnShow also happends to early.
Do you think it shoud be reported to wxwidgets.org?
3 size events instead of previous 4 and no size growing. I suppose it is the answer. I’m not sure that window size is supposed to be equal to it’s client size but screenshots of window with toolbar and some panes before and after restoring geometry become identical after setting GTK_CSD=1. Great thanks for your help.
PS: Is GTK_CSD set in your env?
And everything got explained. Linux Mint with Mate is not using cliend side decorations and everything goes fine. And Ubuntu is using it but doesn’t have GTK_CSD set, so it has issue with window geometry until setting GTK_CSD. Looks like that problem is really fixed in wxWidgets and now it is caused by Ubuntu environment only.
Thank you for your help. Everything looked so weird that I thought I was going crazy.