1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| #! /usr/bin/env python
#-*- coding: utf-8 -*-
import wx
class MyWindow(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, title="Test event")
self.panel = wx.Panel(self, -1)
self.staticText = wx.StaticText(self.panel, -1, "Bipede", style=wx.ALIGN_CENTER)
self.Bind(wx.EVT_CLOSE, self.OnClose)
self.Bind(wx.EVT_SIZE, self.OnSize)
self.staticText.Bind(wx.EVT_LEFT_UP, self.OnClick)
def OnClose(self, event):
self.Destroy()
def OnSize(self, event):
self.panel.SetPosition((0, 0))
self.panel.SetSize(self.GetClientSize())
self.staticText.CentreOnParent()
def OnClick(self, event):
print event.GetEventObject().GetLabel()
class MyApp(wx.App):
def OnInit(self):
f = MyWindow()
f.Show(True)
self.SetTopWindow(f)
return True
app = MyApp()
app.MainLoop() |
Partager