I have a script from a wxPython tutorial, which is included below. The behavior of the script changes depending on how it is invoked. Consider this image, which shows the script invoked two different ways:
The left-hand window was invoked from a terminal (GNOME Terminal 3.40.2) command line like this
The script receives no position events, and the title bar is narrower than the other window. The right-hand window was invoked using the VSCode debugger, and it recieves poistion events, and the (x,y) coordinates change as one moves the window.
I am a little astounded that the command line invocation of he script did not work correctly, a first in my Python on Linux experience. Can anyone explain what is going on, and how to launch a wxPython script that gets events without using VSCode?
Linux: Fedora 34
Widowing System: Wayland
wxPython version: 4.1.1 gtk3 (phoenix) wxWidgets 3.1.5
Python version: 3.9.6
Kernel version: 5.13.12-200.fc34.x86_64 #1 SMP Wed Aug 18 13:27:18 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Hmmm, I have seen several other things that fail to work in the Wayland environment. I wonder if wxPython is one of these. I’ll go search the forums.
Oh, BTW, I am really liking the tutorial where I got this script. Very good for a newbie like me.
------------------- Script Source Code --------------------------------
ZetCode wxPython tutorial
This is a wx.MoveEvent event demostration.
author: Jan Bodnar
last modified: July 2020
def __init__(self, *args, **kw): super(Example, self).__init__(*args, **kw) self.InitUI() def InitUI(self): wx.StaticText(self, label='x:', pos=(10,10)) wx.StaticText(self, label='y:', pos=(10,30)) self.st1 = wx.StaticText(self, label='', pos=(30, 10)) self.st2 = wx.StaticText(self, label='', pos=(30, 30)) self.Bind(wx.EVT_MOVE, self.OnMove) self.SetSize((350, 250)) self.SetTitle('Move event') self.Centre() def OnMove(self, e): x, y = e.GetPosition() self.st1.SetLabel(str(x)) self.st2.SetLabel(str(y))
app = wx.App() ex = Example(None) ex.Show() app.MainLoop()
if name == ‘main’: