wxpython
"Hello World" example that fails to exit.
import sys
import time
import wx
from wx.lib.pubsub import setupkwargs
from wx.lib.pubsub import pub
class LoggerWindow(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, title="Logger")
self._log = wx.TextCtrl(self, style=wx.TE_MULTILINE)
pub.subscribe(self.OnLogMessage, "LOG_MESSAGE")
def OnLogMessage(self, msg):
self._log.AppendText(msg)
class GUI(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, title="Demo GUI - Hello World")
self._logger = LoggerWindow()
pub.sendMessage("LOG_MESSAGE", msg="GUI Starting")
# Set up the Hello World message
self._display = wx.TextCtrl(self, -1, size=(400,20), style=wx.TE_MULTILINE)
self._display.AppendText("Hello World!")
# Show it for a while
self.Show()
time.sleep(10)
# Done
self.Destroy()
App = wx.App()
Gui = GUI()
App.MainLoop()
The log window, while not showing, keeps existing, so the "GUI" window disappears but the app keeps running. I had intended for this to be another example of "not using a loop", but obviously I am using a loop!