]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/demo/GridCustEditor.py
reSWIGged
[wxWidgets.git] / wxPython / demo / GridCustEditor.py
index 50101e4b60a8c63fe70405a3246487fb02736c2e..71b62a7a46b65af756fd04bf089e44f8cd4bbd52 100644 (file)
@@ -1,10 +1,15 @@
-
-from wxPython.wx import *
-from wxPython.grid import *
+# 11/6/2003 - Jeff Grimmett (grimmtooth@softhome.net)
+#
+# Modified for wx namespace
+#
 
 import string
+
+import  wx
+import  wx.grid as gridlib
+
 #---------------------------------------------------------------------------
-class MyCellEditor(wxPyGridCellEditor):
+class MyCellEditor(gridlib.PyGridCellEditor):
     """
     This is a sample GridCellEditor that shows you how to make your own custom
     grid editors.  All the methods that can be overridden are show here.  The
@@ -23,18 +28,19 @@ class MyCellEditor(wxPyGridCellEditor):
     def __init__(self, log):
         self.log = log
         self.log.write("MyCellEditor ctor\n")
-        wxPyGridCellEditor.__init__(self)
+        gridlib.PyGridCellEditor.__init__(self)
 
 
     def Create(self, parent, id, evtHandler):
         """
-        Called to create the control, which must derive from wxControl.
+        Called to create the control, which must derive from wx.Control.
         *Must Override*
         """
         self.log.write("MyCellEditor: Create\n")
-        self._tc = wxTextCtrl(parent, id, "")
+        self._tc = wx.TextCtrl(parent, id, "")
         self._tc.SetInsertionPoint(0)
         self.SetControl(self._tc)
+
         if evtHandler:
             self._tc.PushEventHandler(evtHandler)
 
@@ -47,7 +53,7 @@ class MyCellEditor(wxPyGridCellEditor):
         """
         self.log.write("MyCellEditor: SetSize %s\n" % rect)
         self._tc.SetDimensions(rect.x, rect.y, rect.width+2, rect.height+2,
-                               wxSIZE_ALLOW_MINUS_ONE)
+                               wx.SIZE_ALLOW_MINUS_ONE)
 
 
     def Show(self, show, attr):
@@ -95,6 +101,7 @@ class MyCellEditor(wxPyGridCellEditor):
         changed = False
 
         val = self._tc.GetValue()
+        
         if val != self.startValue:
             changed = True
             grid.GetTable().SetValue(row, col, val) # update the table
@@ -126,7 +133,7 @@ class MyCellEditor(wxPyGridCellEditor):
         ##return self.base_IsAcceptedKey(evt)
 
         return (not (evt.ControlDown() or evt.AltDown()) and
-                evt.GetKeyCode() != WXK_SHIFT)
+                evt.GetKeyCode() != wx.WXK_SHIFT)
 
 
     def StartingKey(self, evt):
@@ -137,9 +144,12 @@ class MyCellEditor(wxPyGridCellEditor):
         self.log.write("MyCellEditor: StartingKey %d\n" % evt.GetKeyCode())
         key = evt.GetKeyCode()
         ch = None
-        if key in [WXK_NUMPAD0, WXK_NUMPAD1, WXK_NUMPAD2, WXK_NUMPAD3, WXK_NUMPAD4,
-                   WXK_NUMPAD5, WXK_NUMPAD6, WXK_NUMPAD7, WXK_NUMPAD8, WXK_NUMPAD9]:
-            ch = ch = chr(ord('0') + key - WXK_NUMPAD0)
+        if key in [ wx.WXK_NUMPAD0, wx.WXK_NUMPAD1, wx.WXK_NUMPAD2, wx.WXK_NUMPAD3, 
+                    wx.WXK_NUMPAD4, wx.WXK_NUMPAD5, wx.WXK_NUMPAD6, wx.WXK_NUMPAD7, 
+                    wx.WXK_NUMPAD8, wx.WXK_NUMPAD9
+                    ]:
+
+            ch = ch = chr(ord('0') + key - wx.WXK_NUMPAD0)
 
         elif key < 256 and key >= 0 and chr(key) in string.printable:
             ch = chr(key)
@@ -180,9 +190,9 @@ class MyCellEditor(wxPyGridCellEditor):
 
 
 #---------------------------------------------------------------------------
-class GridEditorTest(wxGrid):
+class GridEditorTest(gridlib.Grid):
     def __init__(self, parent, log):
-        wxGrid.__init__(self, parent, -1)
+        gridlib.Grid.__init__(self, parent, -1)
         self.log = log
 
         self.CreateGrid(10, 3)
@@ -195,16 +205,17 @@ class GridEditorTest(wxGrid):
         #self.SetDefaultEditor(MyCellEditor(self.log))
 
         # Or we could just do it like this:
-        #self.RegisterDataType(wxGRID_VALUE_STRING,
-        #                      wxGridCellStringRenderer(),
+        #self.RegisterDataType(wx.GRID_VALUE_STRING,
+        #                      wx.GridCellStringRenderer(),
         #                      MyCellEditor(self.log))
+        #                       )
 
         # but for this example, we'll just set the custom editor on one cell
         self.SetCellEditor(1, 0, MyCellEditor(self.log))
         self.SetCellValue(1, 0, "Try to edit this box")
 
         # and on a column
-        attr = wxGridCellAttr()
+        attr = gridlib.GridCellAttr()
         attr.SetEditor(MyCellEditor(self.log))
         self.SetColAttr(2, attr)
         self.SetCellValue(1, 2, "or any in this column")
@@ -216,9 +227,9 @@ class GridEditorTest(wxGrid):
 
 #---------------------------------------------------------------------------
 
-class TestFrame(wxFrame):
+class TestFrame(wx.Frame):
     def __init__(self, parent, log):
-        wxFrame.__init__(self, parent, -1, "Custom Grid Cell Editor Test",
+        wx.Frame.__init__(self, parent, -1, "Custom Grid Cell Editor Test",
                          size=(640,480))
         grid = GridEditorTest(self, log)
 
@@ -226,7 +237,7 @@ class TestFrame(wxFrame):
 
 if __name__ == '__main__':
     import sys
-    app = wxPySimpleApp()
+    app = wx.PySimpleApp()
     frame = TestFrame(None, sys.stdout)
     frame.Show(True)
     app.MainLoop()