Skip to content

Instantly share code, notes, and snippets.

@canwe
Created May 4, 2018 10:16
Show Gist options
  • Select an option

  • Save canwe/c7bef17329d4dbc964f59ea1b42b381c to your computer and use it in GitHub Desktop.

Select an option

Save canwe/c7bef17329d4dbc964f59ea1b42b381c to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
"""
wx Sizer
@author: Dazhuang
"""
import wx
class Frame1(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, parent, title = "Hello World in wxPython")
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)
def OnClick(self, text):
self.text1.AppendText("\nHello, World!")
if __name__ == '__main__':
app = wx.App()
frame = Frame1(None)
frame.Show(True)
app.MainLoop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment