From 7a8be1867e4f203248ef5a1c32ca8cdd580fe972 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Wed, 13 May 2020 20:03:00 +0200 Subject: [PATCH] Cleanup wx examples. - Move toplevel code under `if __name__ == "__main__"` block. (This makes sense specifically for embedding examples as they have very little toplevel code and are indeed otherwise "importable".) - Replace App(0) by App() (the argument defaults to False). - Replace Show(1) by Show() (the arguments defaults to True). --- examples/user_interfaces/embedding_in_wx2_sgskip.py | 6 ++++-- examples/user_interfaces/embedding_in_wx3_sgskip.py | 5 +++-- examples/user_interfaces/embedding_in_wx4_sgskip.py | 7 ++++--- examples/user_interfaces/fourier_demo_wx_sgskip.py | 6 ++++-- examples/user_interfaces/mathtext_wx_sgskip.py | 6 ++++-- examples/user_interfaces/wxcursor_demo_sgskip.py | 2 +- 6 files changed, 20 insertions(+), 12 deletions(-) diff --git a/examples/user_interfaces/embedding_in_wx2_sgskip.py b/examples/user_interfaces/embedding_in_wx2_sgskip.py index d5d1d285cbb2..c2bf57102da2 100644 --- a/examples/user_interfaces/embedding_in_wx2_sgskip.py +++ b/examples/user_interfaces/embedding_in_wx2_sgskip.py @@ -59,5 +59,7 @@ def OnInit(self): return True -app = App(0) -app.MainLoop() + +if __name__ == "__main__": + app = App() + app.MainLoop() diff --git a/examples/user_interfaces/embedding_in_wx3_sgskip.py b/examples/user_interfaces/embedding_in_wx3_sgskip.py index 4f2a016822b2..1dfdc4054d05 100644 --- a/examples/user_interfaces/embedding_in_wx3_sgskip.py +++ b/examples/user_interfaces/embedding_in_wx3_sgskip.py @@ -127,7 +127,7 @@ def OnInit(self): bang_button.Bind(wx.EVT_BUTTON, self.OnBang) # final setup ------------------ - self.frame.Show(1) + self.frame.Show() self.SetTopWindow(self.frame) @@ -139,6 +139,7 @@ def OnBang(self, event): bangs = int(bangs) + 1 bang_count.SetValue(str(bangs)) + if __name__ == '__main__': - app = MyApp(0) + app = MyApp() app.MainLoop() diff --git a/examples/user_interfaces/embedding_in_wx4_sgskip.py b/examples/user_interfaces/embedding_in_wx4_sgskip.py index f79113280d72..77dccda3545c 100644 --- a/examples/user_interfaces/embedding_in_wx4_sgskip.py +++ b/examples/user_interfaces/embedding_in_wx4_sgskip.py @@ -73,8 +73,9 @@ def OnInit(self): """Create the main window and insert the custom frame.""" frame = CanvasFrame() frame.Show(True) - return True -app = App(0) -app.MainLoop() + +if __name__ == "__main__": + app = App() + app.MainLoop() diff --git a/examples/user_interfaces/fourier_demo_wx_sgskip.py b/examples/user_interfaces/fourier_demo_wx_sgskip.py index 74e0ec44e5e9..c11814e7ba7b 100644 --- a/examples/user_interfaces/fourier_demo_wx_sgskip.py +++ b/examples/user_interfaces/fourier_demo_wx_sgskip.py @@ -231,5 +231,7 @@ def OnInit(self): self.frame1.Show() return True -app = App() -app.MainLoop() + +if __name__ == "__main__": + app = App() + app.MainLoop() diff --git a/examples/user_interfaces/mathtext_wx_sgskip.py b/examples/user_interfaces/mathtext_wx_sgskip.py index f1f06040cf72..0b544f96c2a5 100644 --- a/examples/user_interfaces/mathtext_wx_sgskip.py +++ b/examples/user_interfaces/mathtext_wx_sgskip.py @@ -123,5 +123,7 @@ def OnInit(self): frame.Show(True) return True -app = MyApp() -app.MainLoop() + +if __name__ == "__main__": + app = MyApp() + app.MainLoop() diff --git a/examples/user_interfaces/wxcursor_demo_sgskip.py b/examples/user_interfaces/wxcursor_demo_sgskip.py index 7ffd73647923..7269b68159ef 100644 --- a/examples/user_interfaces/wxcursor_demo_sgskip.py +++ b/examples/user_interfaces/wxcursor_demo_sgskip.py @@ -64,5 +64,5 @@ def OnInit(self): if __name__ == '__main__': - app = App(0) + app = App() app.MainLoop() pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy