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/class MySheet(sheet.CSheet):def __init__(self, parent):sheet.CSheet.__init__(self, parent)self.SetNumberRows(50)self.SetNumberCols(50)class Notebook(wx.Frame):def __init__(self, parent, id, title):wx.Frame.__init__(self, parent, id, title, size=(600, 500))menubar = wx.MenuBar()file = wx.Menu()file.Append(101, 'Quit', '' )menubar.Append(file, '&File')self.SetMenuBar(menubar)wx.EVT_MENU(self, 101, self.OnQuit)nb = wx.Notebook(self, -1, style=wx.NB_BOTTOM)self.sheet1 = MySheet(nb)self.sheet2 = MySheet(nb)self.sheet3 = MySheet(nb)nb.AddPage(self.sheet1, 'Sheet1')nb.AddPage(self.sheet2, 'Sheet2')nb.AddPage(self.sheet3, 'Sheet3')self.sheet1.SetFocus()self.StatusBar()self.Centre()self.Show()def StatusBar(self):self.statusbar = self.CreateStatusBar()def OnQuit(self, event):self.Close()app = wx.App()Notebook(None, -1, 'notebook.py')app.MainLoop()In our example we create a notebook widget withwx.NB_BOTTOM style. It is therefore positioned on the bottom ofthe frame accordingly. We add various widgets into the notebookwidget with the AddPage() method. We put simple spreadsheetwidgets. A Spreadsheet widget can be foung in wx.lib.sheetmodule.wx.Panelwx.Panel is a basic parent widget. It adds some basic functionalityto the wx.Window widget, which is usually not used directly.Normally we create a wx.Frame widget first. <strong>The</strong>n we place a26 de 29 27/04/2008 1:04

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

Saved successfully!

Ooh no, something went wrong!