]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/GridEnterHandler.py
   3 import  wx
.grid 
as  gridlib
 
   5 #--------------------------------------------------------------------------- 
   7 class NewEnterHandlingGrid(gridlib
.Grid
): 
   8     def __init__(self
, parent
, log
): 
   9         gridlib
.Grid
.__init
__(self
, parent
, -1) 
  12         self
.CreateGrid(20, 6) 
  14         self
.SetCellValue(0, 0, "Enter moves to the right") 
  15         self
.SetCellValue(0, 5, "Enter wraps to next row") 
  16         self
.SetColSize(0, 150) 
  17         self
.SetColSize(5, 150) 
  19         self
.Bind(wx
.EVT_KEY_DOWN
, self
.OnKeyDown
) 
  22     def OnKeyDown(self
, evt
): 
  23         if evt
.KeyCode() != wx
.WXK_RETURN
: 
  27         if evt
.ControlDown():   # the edit control needs this key 
  31         self
.DisableCellEditControl() 
  32         success 
= self
.MoveCursorRight(evt
.ShiftDown()) 
  35             newRow 
= self
.GetGridCursorRow() + 1 
  37             if newRow 
< self
.GetTable().GetNumberRows(): 
  38                 self
.SetGridCursor(newRow
, 0) 
  39                 self
.MakeCellVisible(newRow
, 0) 
  41                 # this would be a good place to add a new row if your app 
  46 #--------------------------------------------------------------------------- 
  48 class TestFrame(wx
.Frame
): 
  49     def __init__(self
, parent
, log
): 
  50         wx
.Frame
.__init
__(self
, parent
, -1, "Simple Grid Demo", size
=(640,480)) 
  51         grid 
= NewEnterHandlingGrid(self
, log
) 
  55 #--------------------------------------------------------------------------- 
  57 if __name__ 
== '__main__': 
  59     app 
= wx
.PySimpleApp() 
  60     frame 
= TestFrame(None, sys
.stdout
) 
  65 #---------------------------------------------------------------------------