Demo updates for new wx namespace, from Jeff Grimmett

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24723 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2003-12-09 01:23:28 +00:00
parent a61d40115f
commit 8fa876ca9e
147 changed files with 7313 additions and 5154 deletions

View File

@@ -1,16 +1,23 @@
from wxPython.wx import *
from wxPython.grid import *
from wxPython.lib.gridmovers import wxGridColMover, EVT_GRID_COL_MOVE
from wxPython.lib.gridmovers import wxGridRowMover, EVT_GRID_ROW_MOVE
# 11/6/2003 - Jeff Grimmett (grimmtooth@softhome.net)
#
# o Modified for V2.5
#
# 11/25/2003 - Jeff Grimmett (grimmtooth@softhome.net)
#
# o wx renamer didn't appear to 'catch' all the classes in
# wx.lib.gridmovers
# o Event binder not working properly with wx.lib.gridmovers
#
import wx
import wx.grid as gridlib
import wx.lib.gridmovers as gridmovers
#---------------------------------------------------------------------------
class CustomDataTable(wxPyGridTableBase):
"""
"""
class CustomDataTable(gridlib.PyGridTableBase):
def __init__(self, log):
wxPyGridTableBase.__init__(self)
gridlib.PyGridTableBase.__init__(self)
self.log = log
self.identifiers = ['id','ds','sv','pr','pl','op','fx','ts']
@@ -93,10 +100,12 @@ class CustomDataTable(wxPyGridTableBase):
# Move the column
def MoveColumn(self,frm,to):
grid = self.GetView()
if grid:
# Move the identifiers
old = self.identifiers[frm]
del self.identifiers[frm]
if to > frm:
self.identifiers.insert(to-1,old)
else:
@@ -104,23 +113,30 @@ class CustomDataTable(wxPyGridTableBase):
# Notify the grid
grid.BeginBatch()
msg = wxGridTableMessage(self,wxGRIDTABLE_NOTIFY_COLS_DELETED,
frm,1)
msg = gridlib.GridTableMessage(
self, gridlib.GRIDTABLE_NOTIFY_COLS_DELETED, frm, 1
)
grid.ProcessTableMessage(msg)
msg = wxGridTableMessage(self,wxGRIDTABLE_NOTIFY_COLS_INSERTED,
to,1)
msg = gridlib.GridTableMessage(
self, gridlib.GRIDTABLE_NOTIFY_COLS_INSERTED, to, 1
)
grid.ProcessTableMessage(msg)
grid.EndBatch()
# Move the row
def MoveRow(self,frm,to):
grid = self.GetView()
if grid:
# Move the rowLabels and data rows
oldLabel = self.rowLabels[frm]
oldData = self.data[frm]
del self.rowLabels[frm]
del self.data[frm]
if to > frm:
self.rowLabels.insert(to-1,oldLabel)
self.data.insert(to-1,oldData)
@@ -130,11 +146,17 @@ class CustomDataTable(wxPyGridTableBase):
# Notify the grid
grid.BeginBatch()
msg = wxGridTableMessage(self,wxGRIDTABLE_NOTIFY_ROWS_DELETED,
frm,1)
msg = gridlib.GridTableMessage(
self, gridlib.GRIDTABLE_NOTIFY_ROWS_DELETED, frm, 1
)
grid.ProcessTableMessage(msg)
msg = wxGridTableMessage(self,wxGRIDTABLE_NOTIFY_ROWS_INSERTED,
to,1)
msg = gridlib.GridTableMessage(
self, gridlib.GRIDTABLE_NOTIFY_ROWS_INSERTED, to, 1
)
grid.ProcessTableMessage(msg)
grid.EndBatch()
@@ -142,9 +164,9 @@ class CustomDataTable(wxPyGridTableBase):
#---------------------------------------------------------------------------
class DragableGrid(wxGrid):
class DragableGrid(gridlib.Grid):
def __init__(self, parent, log):
wxGrid.__init__(self, parent, -1)
gridlib.Grid.__init__(self, parent, -1)
table = CustomDataTable(log)
@@ -154,12 +176,16 @@ class DragableGrid(wxGrid):
self.SetTable(table, True)
# Enable Column moving
wxGridColMover(self)
EVT_GRID_COL_MOVE(self,self.GetId(),self.OnColMove)
#>> TODO - renamer didn't get this one
gridmovers.wxGridColMover(self)
#>> TODO - Bind() not working here
gridmovers.EVT_GRID_COL_MOVE(self,self.GetId(),self.OnColMove)
# Enable Row moving
wxGridRowMover(self)
EVT_GRID_ROW_MOVE(self,self.GetId(),self.OnRowMove)
#>> TODO - renamer didn't get this one
gridmovers.wxGridRowMover(self)
#>> TODO - Bind() not working here
gridmovers.EVT_GRID_ROW_MOVE(self,self.GetId(),self.OnRowMove)
# Event method called when a column move needs to take place
def OnColMove(self,evt):
@@ -175,9 +201,9 @@ class DragableGrid(wxGrid):
#---------------------------------------------------------------------------
class TestFrame(wxFrame):
class TestFrame(wx.Frame):
def __init__(self, parent, log):
wxFrame.__init__(self, parent, -1, "Custom Table, data driven Grid Demo", size=(640,480))
wx.Frame.__init__(self, parent, -1, "Custom Table, data driven Grid Demo", size=(640,480))
grid = DragableGrid(self, log)
@@ -185,7 +211,7 @@ class TestFrame(wxFrame):
if __name__ == '__main__':
import sys
app = wxPySimpleApp()
app = wx.PySimpleApp()
frame = TestFrame(None, sys.stdout)
frame.Show(True)
app.MainLoop()