diff -r 04a02b4b2a57 -r dd6f693e46a1 RessourceEditor.py --- a/RessourceEditor.py Tue Aug 07 17:37:38 2007 +0200 +++ b/RessourceEditor.py Tue Aug 07 17:38:48 2007 +0200 @@ -22,22 +22,21 @@ #License along with this library; if not, write to the Free Software #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -from wxPython.wx import * -from wxPython.grid import * import wx +import wx.grid #------------------------------------------------------------------------------- # Resource Editor class #------------------------------------------------------------------------------- -class ResourceTable(wxPyGridTableBase): +class ResourceTable(wx.grid.PyGridTableBase): """ - A custom wxGrid Table using user supplied data + A custom wx.grid.Grid Table using user supplied data """ def __init__(self, parent, data, colnames): # The base class must be initialized *first* - wxPyGridTableBase.__init__(self) + wx.grid.PyGridTableBase.__init__(self) self.data = data self.colnames = colnames self.Parent = parent @@ -93,19 +92,19 @@ def ResetView(self, grid): """ - (wxGrid) -> Reset the grid view. Call this to + (wx.grid.Grid) -> Reset the grid view. Call this to update the grid if rows and columns have been added or deleted """ grid.BeginBatch() for current, new, delmsg, addmsg in [ - (self._rows, self.GetNumberRows(), wxGRIDTABLE_NOTIFY_ROWS_DELETED, wxGRIDTABLE_NOTIFY_ROWS_APPENDED), - (self._cols, self.GetNumberCols(), wxGRIDTABLE_NOTIFY_COLS_DELETED, wxGRIDTABLE_NOTIFY_COLS_APPENDED), + (self._rows, self.GetNumberRows(), wx.grid.GRIDTABLE_NOTIFY_ROWS_DELETED, wx.grid.GRIDTABLE_NOTIFY_ROWS_APPENDED), + (self._cols, self.GetNumberCols(), wx.grid.GRIDTABLE_NOTIFY_COLS_DELETED, wx.grid.GRIDTABLE_NOTIFY_COLS_APPENDED), ]: if new < current: - msg = wxGridTableMessage(self,delmsg,new,current-new) + msg = wx.grid.GridTableMessage(self,delmsg,new,current-new) grid.ProcessTableMessage(msg) elif new > current: - msg = wxGridTableMessage(self,addmsg,new-current) + msg = wx.grid.GridTableMessage(self,addmsg,new-current) grid.ProcessTableMessage(msg) self.UpdateValues(grid) grid.EndBatch() @@ -122,20 +121,20 @@ def UpdateValues(self, grid): """Update all displayed values""" # This sends an event to the grid table to update all of the values - msg = wxGridTableMessage(self, wxGRIDTABLE_REQUEST_VIEW_GET_VALUES) + msg = wx.grid.GridTableMessage(self, wx.grid.GRIDTABLE_REQUEST_VIEW_GET_VALUES) grid.ProcessTableMessage(msg) def _updateColAttrs(self, grid): """ - wxGrid -> update the column attributes to add the + wx.grid.Grid -> update the column attributes to add the appropriate renderer given the column name. Otherwise default to the default renderer. """ for col in range(self.GetNumberCols()): - attr = wxGridCellAttr() - attr.SetAlignment(self.ColAlignements[col], wxALIGN_CENTRE) + attr = wx.grid.GridCellAttr() + attr.SetAlignment(self.ColAlignements[col], wx.ALIGN_CENTRE) grid.SetColAttr(col, attr) grid.SetColSize(col, self.ColSizes[col]) @@ -146,29 +145,29 @@ colname = self.GetColLabelValue(col) grid.SetReadOnly(row, col, False) if colname in ["Name","Interval"]: - editor = wxGridCellTextEditor() - renderer = wxGridCellStringRenderer() + editor = wx.grid.GridCellTextEditor() + renderer = wx.grid.GridCellStringRenderer() if colname == "Interval" and self.GetValueByName(row, "Single") != "": grid.SetReadOnly(row, col, True) elif colname == "Single": - editor = wxGridCellChoiceEditor() + editor = wx.grid.GridCellChoiceEditor() editor.SetParameters(self.Parent.VariableList) if self.GetValueByName(row, "Interval") != "": grid.SetReadOnly(row, col, True) elif colname == "Type": - editor = wxGridCellChoiceEditor() + editor = wx.grid.GridCellChoiceEditor() editor.SetParameters(self.Parent.TypeList) elif colname == "Priority": - editor = wxGridCellNumberEditor() + editor = wx.grid.GridCellNumberEditor() editor.SetParameters("0,65535") elif colname == "Task": - editor = wxGridCellChoiceEditor() + editor = wx.grid.GridCellChoiceEditor() editor.SetParameters(self.Parent.TaskList) grid.SetCellEditor(row, col, editor) grid.SetCellRenderer(row, col, renderer) - grid.SetCellBackgroundColour(row, col, wxWHITE) + grid.SetCellBackgroundColour(row, col, wx.WHITE) def SetData(self, data): self.data = data @@ -199,94 +198,69 @@ self.editors = [] -[wxID_RESOURCEEDITOR, wxID_RESOURCEEDITORSTATICTEXT1, - wxID_RESOURCEEDITORSTATICTEXT2, wxID_RESOURCEEDITORINSTANCESGRID, - wxID_RESOURCEEDITORTASKSGRID, wxID_RESOURCEEDITORADDINSTANCEBUTTON, - wxID_RESOURCEEDITORDELETEINSTANCEBUTTON, wxID_RESOURCEEDITORUPINSTANCEBUTTON, - wxID_RESOURCEEDITORDOWNINSTANCEBUTTON, wxID_RESOURCEEDITORADDTASKBUTTON, - wxID_RESOURCEEDITORDELETETASKBUTTON, wxID_RESOURCEEDITORUPTASKBUTTON, - wxID_RESOURCEEDITORDOWNTASKBUTTON, +[ID_RESOURCEEDITOR, ID_RESOURCEEDITORSTATICTEXT1, + ID_RESOURCEEDITORSTATICTEXT2, ID_RESOURCEEDITORINSTANCESGRID, + ID_RESOURCEEDITORTASKSGRID, ID_RESOURCEEDITORADDINSTANCEBUTTON, + ID_RESOURCEEDITORDELETEINSTANCEBUTTON, ID_RESOURCEEDITORUPINSTANCEBUTTON, + ID_RESOURCEEDITORDOWNINSTANCEBUTTON, ID_RESOURCEEDITORADDTASKBUTTON, + ID_RESOURCEEDITORDELETETASKBUTTON, ID_RESOURCEEDITORUPTASKBUTTON, + ID_RESOURCEEDITORDOWNTASKBUTTON, ] = [wx.NewId() for _init_ctrls in range(13)] class ResourceEditor(wx.Panel): def _init_coll_InstancesSizer_Growables(self, parent): - # generated method, don't edit - parent.AddGrowableCol(0) parent.AddGrowableRow(1) def _init_coll_InstancesSizer_Items(self, parent): - # generated method, don't edit - - parent.AddSizer(self.InstancesButtonsSizer, 0, border=0, flag=wxGROW) - parent.AddWindow(self.InstancesGrid, 0, border=0, flag=wxGROW) + parent.AddSizer(self.InstancesButtonsSizer, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.InstancesGrid, 0, border=0, flag=wx.GROW) def _init_coll_InstancesButtonsSizer_Growables(self, parent): - # generated method, don't edit - parent.AddGrowableCol(0) parent.AddGrowableRow(0) def _init_coll_InstancesButtonsSizer_Items(self, parent): - # generated method, don't edit - - parent.AddWindow(self.staticText2, 0, border=0, flag=wxALIGN_BOTTOM) + parent.AddWindow(self.staticText2, 0, border=0, flag=wx.ALIGN_BOTTOM) parent.AddWindow(self.AddInstanceButton, 0, border=0, flag=0) parent.AddWindow(self.DeleteInstanceButton, 0, border=0, flag=0) parent.AddWindow(self.UpInstanceButton, 0, border=0, flag=0) parent.AddWindow(self.DownInstanceButton, 0, border=0, flag=0) def _init_coll_TasksSizer_Growables(self, parent): - # generated method, don't edit - parent.AddGrowableCol(0) parent.AddGrowableRow(1) def _init_coll_TasksSizer_Items(self, parent): - # generated method, don't edit - - parent.AddSizer(self.TasksButtonsSizer, 0, border=0, flag=wxGROW) - parent.AddWindow(self.TasksGrid, 0, border=0, flag=wxGROW) + parent.AddSizer(self.TasksButtonsSizer, 0, border=0, flag=wx.GROW) + parent.AddWindow(self.TasksGrid, 0, border=0, flag=wx.GROW) def _init_coll_TasksButtonsSizer_Growables(self, parent): - # generated method, don't edit - parent.AddGrowableCol(0) parent.AddGrowableRow(0) def _init_coll_TasksButtonsSizer_Items(self, parent): - # generated method, don't edit - - parent.AddWindow(self.staticText1, 0, border=0, flag=wxALIGN_BOTTOM) + parent.AddWindow(self.staticText1, 0, border=0, flag=wx.ALIGN_BOTTOM) parent.AddWindow(self.AddTaskButton, 0, border=0, flag=0) parent.AddWindow(self.DeleteTaskButton, 0, border=0, flag=0) parent.AddWindow(self.UpTaskButton, 0, border=0, flag=0) parent.AddWindow(self.DownTaskButton, 0, border=0, flag=0) def _init_coll_MainGridSizer_Items(self, parent): - # generated method, don't edit - - parent.AddSizer(self.TasksSizer, 0, border=0, flag=wxGROW) - parent.AddSizer(self.InstancesSizer, 0, border=0, flag=wxGROW) + parent.AddSizer(self.TasksSizer, 0, border=0, flag=wx.GROW) + parent.AddSizer(self.InstancesSizer, 0, border=0, flag=wx.GROW) def _init_coll_MainGridSizer_Growables(self, parent): - # generated method, don't edit - parent.AddGrowableCol(0) parent.AddGrowableRow(0) parent.AddGrowableRow(1) def _init_sizers(self): - # generated method, don't edit self.MainGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) - self.InstancesSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) - self.InstancesButtonsSizer = wx.FlexGridSizer(cols=5, hgap=5, rows=1, vgap=0) - self.TasksSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) - self.TasksButtonsSizer = wx.FlexGridSizer(cols=5, hgap=5, rows=1, vgap=0) self._init_coll_MainGridSizer_Growables(self.MainGridSizer) @@ -303,76 +277,75 @@ self.SetSizer(self.MainGridSizer) def _init_ctrls(self, prnt): - # generated method, don't edit - wx.Panel.__init__(self, id=wxID_RESOURCEEDITOR, name='', parent=prnt, + wx.Panel.__init__(self, id=ID_RESOURCEEDITOR, name='', parent=prnt, pos=wx.Point(0, 0), size=wx.Size(-1, -1), style=wx.SUNKEN_BORDER) - self.staticText1 = wx.StaticText(id=wxID_RESOURCEEDITORSTATICTEXT1, + self.staticText1 = wx.StaticText(id=ID_RESOURCEEDITORSTATICTEXT1, label=u'Tasks:', name='staticText2', parent=self, pos=wx.Point(0, - 0), size=wx.Size(60, 17), style=wxALIGN_CENTER) - - self.TasksGrid = wx.grid.Grid(id=wxID_RESOURCEEDITORTASKSGRID, + 0), size=wx.Size(60, 17), style=wx.ALIGN_CENTER) + + self.TasksGrid = wx.grid.Grid(id=ID_RESOURCEEDITORTASKSGRID, name='TasksGrid', parent=self, pos=wx.Point(0, 0), - size=wx.Size(-1, -1), style=wxVSCROLL) + size=wx.Size(-1, -1), style=wx.VSCROLL) self.TasksGrid.SetFont(wx.Font(12, 77, wx.NORMAL, wx.NORMAL, False, 'Sans')) self.TasksGrid.SetLabelFont(wx.Font(10, 77, wx.NORMAL, wx.NORMAL, False, 'Sans')) - EVT_GRID_CELL_CHANGE(self.TasksGrid, self.OnTasksGridCellChange) - - self.AddTaskButton = wx.Button(id=wxID_RESOURCEEDITORADDTASKBUTTON, label='Add Task', + self.TasksGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnTasksGridCellChange) + + self.AddTaskButton = wx.Button(id=ID_RESOURCEEDITORADDTASKBUTTON, label='Add Task', name='AddTaskButton', parent=self, pos=wx.Point(0, 0), size=wx.Size(102, 32), style=0) - EVT_BUTTON(self, wxID_RESOURCEEDITORADDTASKBUTTON, self.OnAddTaskButton) - - self.DeleteTaskButton = wx.Button(id=wxID_RESOURCEEDITORDELETETASKBUTTON, label='Delete Task', + self.Bind(wx.EVT_BUTTON, self.OnAddTaskButton, id=ID_RESOURCEEDITORADDTASKBUTTON) + + self.DeleteTaskButton = wx.Button(id=ID_RESOURCEEDITORDELETETASKBUTTON, label='Delete Task', name='DeleteTaskButton', parent=self, pos=wx.Point(0, 0), size=wx.Size(102, 32), style=0) - EVT_BUTTON(self, wxID_RESOURCEEDITORDELETETASKBUTTON, self.OnDeleteTaskButton) - - self.UpTaskButton = wx.Button(id=wxID_RESOURCEEDITORUPTASKBUTTON, label='^', + self.Bind(wx.EVT_BUTTON, self.OnDeleteTaskButton, id=ID_RESOURCEEDITORDELETETASKBUTTON) + + self.UpTaskButton = wx.Button(id=ID_RESOURCEEDITORUPTASKBUTTON, label='^', name='UpTaskButton', parent=self, pos=wx.Point(0, 0), size=wx.Size(32, 32), style=0) - EVT_BUTTON(self, wxID_RESOURCEEDITORUPTASKBUTTON, self.OnUpTaskButton) - - self.DownTaskButton = wx.Button(id=wxID_RESOURCEEDITORDOWNTASKBUTTON, label='v', + self.Bind(wx.EVT_BUTTON, self.OnUpTaskButton, id=ID_RESOURCEEDITORUPTASKBUTTON) + + self.DownTaskButton = wx.Button(id=ID_RESOURCEEDITORDOWNTASKBUTTON, label='v', name='DownTaskButton', parent=self, pos=wx.Point(0, 0), size=wx.Size(32, 32), style=0) - EVT_BUTTON(self, wxID_RESOURCEEDITORDOWNTASKBUTTON, self.OnDownTaskButton) - - self.staticText2 = wx.StaticText(id=wxID_RESOURCEEDITORSTATICTEXT2, + self.Bind(wx.EVT_BUTTON, self.OnDownTaskButton, id=ID_RESOURCEEDITORDOWNTASKBUTTON) + + self.staticText2 = wx.StaticText(id=ID_RESOURCEEDITORSTATICTEXT2, label=u'Instances:', name='staticText1', parent=self, - pos=wx.Point(0, 0), size=wx.Size(85, 17), style=wxALIGN_CENTER) - - self.InstancesGrid = wx.grid.Grid(id=wxID_RESOURCEEDITORINSTANCESGRID, + pos=wx.Point(0, 0), size=wx.Size(85, 17), style=wx.ALIGN_CENTER) + + self.InstancesGrid = wx.grid.Grid(id=ID_RESOURCEEDITORINSTANCESGRID, name='InstancesGrid', parent=self, pos=wx.Point(0, 0), - size=wx.Size(-1, -1), style=wxVSCROLL) + size=wx.Size(-1, -1), style=wx.VSCROLL) self.InstancesGrid.SetFont(wx.Font(12, 77, wx.NORMAL, wx.NORMAL, False, 'Sans')) self.InstancesGrid.SetLabelFont(wx.Font(10, 77, wx.NORMAL, wx.NORMAL, False, 'Sans')) - EVT_GRID_CELL_CHANGE(self.InstancesGrid, self.OnInstancesGridCellChange) - - self.AddInstanceButton = wx.Button(id=wxID_RESOURCEEDITORADDINSTANCEBUTTON, label='Add Instance', + self.InstancesGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnInstancesGridCellChange) + + self.AddInstanceButton = wx.Button(id=ID_RESOURCEEDITORADDINSTANCEBUTTON, label='Add Instance', name='AddInstanceButton', parent=self, pos=wx.Point(0, 0), size=wx.Size(122, 32), style=0) - EVT_BUTTON(self, wxID_RESOURCEEDITORADDINSTANCEBUTTON, self.OnAddInstanceButton) - - self.DeleteInstanceButton = wx.Button(id=wxID_RESOURCEEDITORDELETEINSTANCEBUTTON, label='Delete Instance', + self.Bind(wx.EVT_BUTTON, self.OnAddInstanceButton, id=ID_RESOURCEEDITORADDINSTANCEBUTTON) + + self.DeleteInstanceButton = wx.Button(id=ID_RESOURCEEDITORDELETEINSTANCEBUTTON, label='Delete Instance', name='DeleteInstanceButton', parent=self, pos=wx.Point(0, 0), size=wx.Size(122, 32), style=0) - EVT_BUTTON(self, wxID_RESOURCEEDITORDELETEINSTANCEBUTTON, self.OnDeleteInstanceButton) - - self.UpInstanceButton = wx.Button(id=wxID_RESOURCEEDITORUPINSTANCEBUTTON, label='^', + self.Bind(wx.EVT_BUTTON, self.OnDeleteInstanceButton, id=ID_RESOURCEEDITORDELETEINSTANCEBUTTON) + + self.UpInstanceButton = wx.Button(id=ID_RESOURCEEDITORUPINSTANCEBUTTON, label='^', name='UpInstanceButton', parent=self, pos=wx.Point(0, 0), size=wx.Size(32, 32), style=0) - EVT_BUTTON(self, wxID_RESOURCEEDITORUPINSTANCEBUTTON, self.OnUpInstanceButton) - - self.DownInstanceButton = wx.Button(id=wxID_RESOURCEEDITORDOWNINSTANCEBUTTON, label='v', + self.Bind(wx.EVT_BUTTON, self.OnUpInstanceButton, id=ID_RESOURCEEDITORUPINSTANCEBUTTON) + + self.DownInstanceButton = wx.Button(id=ID_RESOURCEEDITORDOWNINSTANCEBUTTON, label='v', name='DownInstanceButton', parent=self, pos=wx.Point(0, 0), size=wx.Size(32, 32), style=0) - EVT_BUTTON(self, wxID_RESOURCEEDITORDOWNINSTANCEBUTTON, self.OnDownInstanceButton) + self.Bind(wx.EVT_BUTTON, self.OnDownInstanceButton, id=ID_RESOURCEEDITORDOWNINSTANCEBUTTON) self._init_sizers() @@ -384,7 +357,7 @@ self.TasksDefaultValue = {"Name" : "", "Single" : "", "Interval" : "", "Priority" : 0} self.TasksTable = ResourceTable(self, [], ["Name", "Single", "Interval", "Priority"]) - self.TasksTable.SetColAlignements([wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_RIGHT, wxALIGN_RIGHT]) + self.TasksTable.SetColAlignements([wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_RIGHT, wx.ALIGN_RIGHT]) self.TasksTable.SetColSizes([200, 100, 100, 100]) self.TasksGrid.SetTable(self.TasksTable) self.TasksGrid.SetRowLabelSize(0) @@ -392,7 +365,7 @@ self.InstancesDefaultValue = {"Name" : "", "Type" : "", "Task" : ""} self.InstancesTable = ResourceTable(self, [], ["Name", "Type", "Task"]) - self.InstancesTable.SetColAlignements([wxALIGN_LEFT, wxALIGN_LEFT, wxALIGN_LEFT]) + self.InstancesTable.SetColAlignements([wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT]) self.InstancesTable.SetColSizes([200, 150, 150]) self.InstancesGrid.SetTable(self.InstancesTable) self.InstancesGrid.SetRowLabelSize(0)