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:
import os
import sys
import wx
import wx.propgrid
import wx.lib.agw.persist as pm
dirName = os.path.dirname(os.path.abspath(sys.argv[0]))
class Window(wx.Frame):
def __init__(self):
super().__init__(None)
self.SetName('wnd')
self.persist = pm.PersistenceManager.Get()
self.persist_file = os.path.join(dirName, "Persist.conf")
self.persist.SetPersistenceFile(self.persist_file)
self.Bind(wx.EVT_CLOSE, self.OnClose)
wx.CallAfter(self.register_persist)
def register_persist(self):
self.Freeze()
if not self.persist.RegisterAndRestore(self):
self.SetSize(300, 200)
self.Thaw()
def OnClose(self, event):
print(f'window size: {self.GetSize()}')
self.persist.SaveAndUnregister()
event.Skip()
if __name__ == '__main__':
app = wx.App()
window = Window()
window.Show()
app.MainLoop()
I would be grateful for any hint.