Hi. I am using Fedora 32, wxPython 4.1.1 on Python3.8.9 on Wayland.
I have to use wayland because otherwise richtextctrl can not paste correctly.
Now I have a new problem. Centering a dialog does not work.
In fact this is a known problem python - wxpython on Wayland is unable to interact with screen coordinates (move a window, GetScreenPosition, etc.) - Stack Overflow
At the same time calling ShowModal()
does somehow center the dialog on parent, Show()
does not.
Is there a way I can force a dialog to center on parent on Wayland and use the Show()
function?
Or is there any hope that this problem will be fixed soon?
Small example:
import wx
class TestFrame(wx.Frame):
def __init__(self, *args, **kw):
wx.Frame.__init__(self, *args, **kw)
self._main_sizer = wx.BoxSizer(wx.VERTICAL)
self.SetSizer(self._main_sizer)
def dlg_test(self) -> None:
TestDialog(self)
class MyApp(wx.App):
"""
Main class for running the gui.
"""
def __init__(self):
wx.App.__init__(self)
self.frame = None
def OnInit(self):
self.frame = TestFrame(None, -1, "Test", size=(500, 500), style=wx.DEFAULT_FRAME_STYLE)
self.SetTopWindow(self.frame)
self.frame.Show()
self.frame.dlg_test()
return True
class TestDialog(wx.Dialog):
def __init__(self, parent):
wx.Dialog.__init__(self, parent, title='Strings', size=(200, 200))
self._main_vertical_sizer = wx.BoxSizer(wx.VERTICAL)
self.SetSizer(self._main_vertical_sizer)
self.CenterOnParent()
# Show modal shows centered, show alone does not.
self.Show()
# self.Destroy()
#self.ShowModal()
if __name__ == "__main__":
app = MyApp()
app.MainLoop()
Thanks.