Hello,
I’m reading Michael Driscoll’s “Creating GUI Applications with wxPython” to learn how to write scripts in Phoenixø.
I notice this script takes a few seconds to close in the DOS terminal window after I close the GUI:
#Python 3.12.0
#wxPython 4.2.1
import wx,sys
class MyPanel(wx.Panel):
def __init__(self, parent):
super().__init__(parent)
self.Bind(wx.EVT_CHAR_HOOK, self.OnKeyUP)
self.text = wx.TextCtrl ( self, value = "Line1\r\nLine2", style = wx.TE_READONLY | wx.TE_MULTILINE)
#How to "grey out" background to show text widget is read only?
#BAD self.text.Disable()
main_sizer = wx.BoxSizer(wx.HORIZONTAL)
main_sizer.Add(self.text, proportion=1, flag=wx.ALL | wx.CENTER | wx.EXPAND, border=5)
self.SetSizer(main_sizer)
def OnKeyUP(self, event):
keyCode = event.GetKeyCode()
if keyCode == wx.WXK_ESCAPE:
#NOTHING self.Close()
sys.exit(0)
#event.Skip()
class MyFrame(wx.Frame):
def __init__(self):
super().__init__(None, title='Banks')
panel = MyPanel(self)
self.Show()
if __name__ == '__main__':
app = wx.App()
frame = MyFrame()
app.MainLoop()
FWIW, here’s what PyScripter IDE says:
…
*** Remote Interpreter Reinitialized ***
Traceback (most recent call last):
File "C:\PyScripter\Lib\rpyc.zip\rpyc\core\stream.py", line 214, in read
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\PyScripter\Lib\rpyc.zip\rpyc\core\netref.py", line 208, in __call__
File "C:\PyScripter\Lib\rpyc.zip\rpyc\core\netref.py", line 76, in syncreq
File "C:\PyScripter\Lib\rpyc.zip\rpyc\core\protocol.py", line 471, in sync_request
File "C:\PyScripter\Lib\rpyc.zip\rpyc\core\async_.py", line 95, in value
File "C:\PyScripter\Lib\rpyc.zip\rpyc\core\async_.py", line 45, in wait
File "C:\PyScripter\Lib\rpyc.zip\rpyc\core\protocol.py", line 387, in serve
File "C:\PyScripter\Lib\rpyc.zip\rpyc\core\channel.py", line 50, in recv
File "C:\PyScripter\Lib\rpyc.zip\rpyc\core\stream.py", line 223, in read
EOFError: [WinError 10054] An existing connection was forcibly closed by the remote host
Traceback (most recent call last):
File "C:\PyScripter\Lib\rpyc.zip\rpyc\core\netref.py", line 152, in __getattribute__
File "C:\PyScripter\Lib\rpyc.zip\rpyc\core\netref.py", line 76, in syncreq
File "C:\PyScripter\Lib\rpyc.zip\rpyc\core\protocol.py", line 471, in sync_request
File "C:\PyScripter\Lib\rpyc.zip\rpyc\core\protocol.py", line 492, in async_request
File "C:\PyScripter\Lib\rpyc.zip\rpyc\core\protocol.py", line 477, in _async_request
File "C:\PyScripter\Lib\rpyc.zip\rpyc\core\protocol.py", line 259, in _send
File "C:\PyScripter\Lib\rpyc.zip\rpyc\core\channel.py", line 69, in send
File "C:\PyScripter\Lib\rpyc.zip\rpyc\core\stream.py", line 233, in write
File "C:\PyScripter\Lib\rpyc.zip\rpyc\core\stream.py", line 81, in __getattr__
EOFError: stream has been closed
>>>
*** Remote Interpreter Reinitialized ***
Thank you.
ø BTW, is it the only book that covers wxW4 ? Are wikis etc. the only alternative?