Skip to content

Instantly share code, notes, and snippets.

@canwe
Created May 4, 2018 10:08
Show Gist options
  • Save canwe/e9f250fd035e85843dcfd49db2ea0ffb to your computer and use it in GitHub Desktop.
Save canwe/e9f250fd035e85843dcfd49db2ea0ffb to your computer and use it in GitHub Desktop.
# Filename: helloworldbtn.py
import wx
class Frame1(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, title = title)
panel = wx.Panel(self)
sizer = wx.BoxSizer(wx.VERTICAL)
self.text1= wx.TextCtrl(panel, value = "Hello, World!", size = (200,180), style = wx.TE_MULTILINE)
sizer.Add(self.text1, 0, wx.ALIGN_TOP | wx.EXPAND)
button = wx.Button(panel, label = "Click Me")
sizer.Add(button)
panel.SetSizerAndFit(sizer)
panel.Layout()
self.Bind(wx.EVT_BUTTON,self.OnClick,button)
self.Show(True)
def OnClick(self, text):
self.text1.AppendText("\nHello, World!")
if __name__ == '__main__':
app =wx.App()
frame = Frame1(None, "Hello World in wxPython")
app.MainLoop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment