]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/GridEnterHandler.py
1 # 11/6/2003 - Jeff Grimmett (grimmtooth@softhome.net)
3 # o Updated for wx namespace
7 import wx
.grid
as gridlib
9 #---------------------------------------------------------------------------
11 class NewEnterHandlingGrid(gridlib
.Grid
):
12 def __init__(self
, parent
, log
):
13 gridlib
.Grid
.__init
__(self
, parent
, -1)
16 self
.CreateGrid(20, 6)
18 self
.SetCellValue(0, 0, "Enter moves to the right")
19 self
.SetCellValue(0, 5, "Enter wraps to next row")
20 self
.SetColSize(0, 150)
21 self
.SetColSize(5, 150)
23 self
.Bind(wx
.EVT_KEY_DOWN
, self
.OnKeyDown
)
26 def OnKeyDown(self
, evt
):
27 if evt
.KeyCode() != wx
.WXK_RETURN
:
31 if evt
.ControlDown(): # the edit control needs this key
35 self
.DisableCellEditControl()
36 success
= self
.MoveCursorRight(evt
.ShiftDown())
39 newRow
= self
.GetGridCursorRow() + 1
41 if newRow
< self
.GetTable().GetNumberRows():
42 self
.SetGridCursor(newRow
, 0)
43 self
.MakeCellVisible(newRow
, 0)
45 # this would be a good place to add a new row if your app
50 #---------------------------------------------------------------------------
52 class TestFrame(wx
.Frame
):
53 def __init__(self
, parent
, log
):
54 wx
.Frame
.__init
__(self
, parent
, -1, "Simple Grid Demo", size
=(640,480))
55 grid
= NewEnterHandlingGrid(self
, log
)
59 #---------------------------------------------------------------------------
61 if __name__
== '__main__':
63 app
= wx
.PySimpleApp()
64 frame
= TestFrame(None, sys
.stdout
)
69 #---------------------------------------------------------------------------