13.07.2015 Views

The wxPython tutorial

The wxPython tutorial

The wxPython tutorial

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>wxPython</strong> widgetshttp://www.zetcode.com/wxpython/widgets/Figure: Buttons.py#!/usr/bin/python# buttons.pyimport wximport randomAPP_SIZE_X = 300APP_SIZE_Y = 200class MyButtons(wx.Dialog):def __init__(self, parent, id, title):wx.Dialog.__init__(self, parent, id, title, size=(APP_SIZE_X, APP_SIZE_Y))wx.Button(self, 1, 'Close', (50, 130))wx.Button(self, 2, 'Random Move', (150, 130), (110, -1))self.Bind(wx.EVT_BUTTON, self.OnClose, id=1)self.Bind(wx.EVT_BUTTON, self.OnRandomMove, id=2)self.Centre()self.ShowModal()self.Destroy()def OnClose(self, event):self.Close(True)def OnRandomMove(self, event):screensize = wx.GetDisplaySize()randx = random.randrange(0, screensize.x - APP_SIZE_X)randy = random.randrange(0, screensize.y - APP_SIZE_Y)self.Move((randx, randy))app = wx.App(0)MyButtons(None, -1, 'buttons.py')app.MainLoop()wx.ToggleButton2 de 29 27/04/2008 1:04

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!