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/class MySheet(CSheet):def __init__(self, parent):CSheet.__init__(self, parent)Our example inherits from CSheet class. It is a grid widgetwith some additional logic.self.SetRowLabelAlignment(wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)Here we center the labels in rows. By default, they arealigned to the right.r = event.GetRow()c = event.GetCol()text = self.GetCellValue(r, c)# self.text - text before change# text - text after changeundo = UndoText(self, self.text, text, r, c)stockUndo.append(undo)Every time we do some changes, an UndoText object iscreated and appended to the stockUndo list..if stockRedo:# this might be surprising, but it is a standard behaviour# in all spreadsheetsdel stockRedo[:]toolbar.EnableTool(ID_REDO, False)Yes, this behaviour was surprising for me. I did not knowthat it works this way, until I made this example. Basically,if you undo some changes and then start typing again, allredo changes are lost. OpenOffice Calc works this way.Gnumeric as well.if len(stockUndo) == 0:self.toolbar.EnableTool(ID_UNDO, False)...self.toolbar.EnableTool(ID_REDO, True)<strong>The</strong> undo and redo buttons are enabled or disabled10 de 15 27/04/2008 1:09

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

Saved successfully!

Ooh no, something went wrong!