13.07.2015 Views

The wxPython tutorial

The wxPython tutorial

The wxPython tutorial

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

http://www.zetcode.com/wxpython/tips/self.sheet1 = MySheet(self)self.sheet1.SetNumberRows(55)self.sheet1.SetNumberCols(25)for i in range(self.sheet1.GetNumberRows()):self.sheet1.SetRowSize(i, ID_ROWSIZE)self.sheet1.SetFocus()box.Add(self.sheet1, 1, wx.EXPAND)self.CreateStatusBar()self.Centre()self.Show(True)def OnUndo(self, event):if len(stockUndo) == 0:returna = stockUndo.pop()if len(stockUndo) == 0:self.toolbar.EnableTool(ID_UNDO, False)a.undo()stockRedo.append(a)self.toolbar.EnableTool(ID_REDO, True)def OnRedo(self, event):if len(stockRedo) == 0:returna = stockRedo.pop()if len(stockRedo) == 0:self.toolbar.EnableTool(ID_REDO, False)a.redo()stockUndo.append(a)self.toolbar.EnableTool(ID_UNDO, True)def OnQuitNewt(self, event):self.Close(True)app = wx.App()Newt(None, -1, 'Newt')app.MainLoop()stockUndo = []stockRedo = []<strong>The</strong>re are two list objects. stockUndo is a list that holds allchanges, that we can undo. stockRedo keeps all changes,that can be redone. <strong>The</strong> changes are instantiated into aUndoText object. This object has two methods. undo andredo.9 de 15 27/04/2008 1:09

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

Saved successfully!

Ooh no, something went wrong!