]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/GridEnterHandler.py
1 from wxPython
.wx
import *
2 from wxPython
.grid
import *
4 #---------------------------------------------------------------------------
6 class NewEnterHandlingGrid(wxGrid
):
7 def __init__(self
, parent
, log
):
8 wxGrid
.__init
__(self
, parent
, -1)
11 self
.CreateGrid(20, 6)
13 self
.SetCellValue(0, 0, "Enter moves to the right")
14 self
.SetCellValue(0, 5, "Enter wraps to next row")
15 self
.SetColSize(0, 150)
16 self
.SetColSize(5, 150)
18 EVT_KEY_DOWN(self
, self
.OnKeyDown
)
21 def OnKeyDown(self
, evt
):
22 if evt
.KeyCode() != WXK_RETURN
:
26 if evt
.ControlDown(): # the edit control needs this key
30 self
.DisableCellEditControl()
31 success
= self
.MoveCursorRight(evt
.ShiftDown())
33 newRow
= self
.GetGridCursorRow() + 1
34 if newRow
< self
.GetTable().GetNumberRows():
35 self
.SetGridCursor(newRow
, 0)
36 self
.MakeCellVisible(newRow
, 0)
38 # this would be a good place to add a new row if your app
43 #---------------------------------------------------------------------------
45 class TestFrame(wxFrame
):
46 def __init__(self
, parent
, log
):
47 wxFrame
.__init
__(self
, parent
, -1, "Simple Grid Demo", size
=(640,480))
48 grid
= NewEnterHandlingGrid(self
, log
)
52 #---------------------------------------------------------------------------
54 if __name__
== '__main__':
57 frame
= TestFrame(None, sys
.stdout
)
62 #---------------------------------------------------------------------------