Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
WxPython
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Use == wxPython enables Python to be used for [[Cross-platform software|cross-platform]] [[graphical user interface|GUI]] applications requiring very little, if any, platform-specific code. === Example === This is a simple "[[Hello world program|Hello world]]" module, depicting the creation of the two main [[Object (computer science)|objects]] in wxPython (the main window object and the application object), followed by passing the control to the [[Event-driven programming|event-driven]] system (by calling <code>MainLoop()</code>) which manages the user-interactive part of the program. <syntaxhighlight lang="python"> #!/usr/bin/env python3 import wx app = wx.App(False) # Create a new app, don't redirect stdout/stderr to a window. frame = wx.Frame(None, title="Hello World") # A Frame is a top-level window. frame.Show(True) # Show the frame. app.MainLoop() </syntaxhighlight> This is another example of the wxPython Close Button with wxPython GUI display show in Windows 10 operating system.[[File:Close button with wxpython in windows 10.png|thumb|Close button with wxPython shown on Windows 10]] <syntaxhighlight lang="python3"> import wx class WxButton(wx.Frame): def __init__(self, *args, **kw): super(WxButton, self).__init__(*args, **kw) self.InitUI() def InitUI(self): pnl = wx.Panel(self) closeButton = wx.Button(pnl, label='Close Me', pos=(20, 20)) closeButton.Bind(wx.EVT_BUTTON, self.OnClose) self.SetSize((350, 250)) self.SetTitle('Close Button') self.Centre() def OnClose(self, e): self.Close(True) def main(): app = wx.App() ex = WxButton(None) ex.Show() app.MainLoop() if __name__ == "__main__": main() </syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)