X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/83625579234e2dfd760c7380d267f0f0c1e53be6..aeec2045cf0fd285e12546dc4eceb9440c3dec51:/wxPython/demo/GridCustEditor.py diff --git a/wxPython/demo/GridCustEditor.py b/wxPython/demo/GridCustEditor.py index f90ea1f2f5..50101e4b60 100644 --- a/wxPython/demo/GridCustEditor.py +++ b/wxPython/demo/GridCustEditor.py @@ -1,8 +1,8 @@ -#!/usr/bin/env python from wxPython.wx import * from wxPython.grid import * +import string #--------------------------------------------------------------------------- class MyCellEditor(wxPyGridCellEditor): """ @@ -46,7 +46,8 @@ class MyCellEditor(wxPyGridCellEditor): PaintBackground and do something meaningful there. """ self.log.write("MyCellEditor: SetSize %s\n" % rect) - self._tc.SetDimensions(rect.x, rect.y, rect.width+2, rect.height+2) + self._tc.SetDimensions(rect.x, rect.y, rect.width+2, rect.height+2, + wxSIZE_ALLOW_MINUS_ONE) def Show(self, show, attr): @@ -86,16 +87,16 @@ class MyCellEditor(wxPyGridCellEditor): def EndEdit(self, row, col, grid): """ - Complete the editing of the current cell. Returns true if the value + Complete the editing of the current cell. Returns True if the value has changed. If necessary, the control may be destroyed. *Must Override* """ self.log.write("MyCellEditor: EndEdit (%d,%d)\n" % (row, col)) - changed = false + changed = False val = self._tc.GetValue() if val != self.startValue: - changed = true + changed = True grid.GetTable().SetValue(row, col, val) # update the table self.startValue = '' @@ -115,7 +116,7 @@ class MyCellEditor(wxPyGridCellEditor): def IsAcceptedKey(self, evt): """ - Return TRUE to allow the given key to start editing: the base class + Return True to allow the given key to start editing: the base class version only checks that the event has no modifiers. F2 is special and will always start the editor. """ @@ -124,7 +125,8 @@ class MyCellEditor(wxPyGridCellEditor): ## Oops, there's a bug here, we'll have to do it ourself.. ##return self.base_IsAcceptedKey(evt) - return not evt.HasModifiers() and evt.GetKeyCode() != WXK_SHIFT + return (not (evt.ControlDown() or evt.AltDown()) and + evt.GetKeyCode() != WXK_SHIFT) def StartingKey(self, evt): @@ -142,12 +144,13 @@ class MyCellEditor(wxPyGridCellEditor): elif key < 256 and key >= 0 and chr(key) in string.printable: ch = chr(key) if not evt.ShiftDown(): - ch = string.lower(ch) + ch = ch.lower() if ch is not None: # For this example, replace the text. Normally we would append it. #self._tc.AppendText(ch) self._tc.SetValue(ch) + self._tc.SetInsertionPointEnd() else: evt.Skip() @@ -210,6 +213,7 @@ class GridEditorTest(wxGrid): self.SetColSize(1, 150) self.SetColSize(2, 150) + #--------------------------------------------------------------------------- class TestFrame(wxFrame): @@ -224,7 +228,7 @@ if __name__ == '__main__': import sys app = wxPySimpleApp() frame = TestFrame(None, sys.stdout) - frame.Show(true) + frame.Show(True) app.MainLoop()