lpcmanager

Parents 9b18df89c4c1
Children 312aab2b1d50
#2566 stripped wrong way to hook dialog to grid cell - use cell editor instead
  • +0 -72
    LPCManager.py
  • --- a/LPCManager.py Tue Feb 06 13:07:04 2018 +0100
    +++ b/LPCManager.py Tue Feb 06 13:56:30 2018 +0100
    @@ -107,14 +107,10 @@
    AddBitmapFolder(os.path.join(_lpcmanager_path, "images"))
    -from editors.ConfTreeNodeEditor import ConfTreeNodeEditor
    -from editors.CodeFileEditor import VariablesTable
    -from editors.CodeFileEditor import VariablesEditor
    from editors.CodeFileEditor import CodeEditor
    from controls import ProjectPropertiesPanel
    from controls.SearchResultPanel import SearchResultPanel
    # from controls.LogViewer import LogViewer
    -from WampOptionsEditor import WampOptionsEditor
    from VariableExporter import VariableWriter
    from PLCControler import PLCControler, ITEMS_UNEDITABLE, ITEM_POU
    from wx.lib.scrolledpanel import ScrolledPanel
    @@ -718,74 +714,6 @@
    self.Language.Append(language)
    ProjectPropertiesPanel.__init__ = OurProjectPropertiesPanelInit
    -
    -def LeftClick(self, event):
    - if event.GetCol() == self.grid.GetNumberCols()-1:
    - options = [self.grid.GetCellValue(event.GetRow(), event.GetCol()), self.grid.GetCellValue(event.GetRow(), event.GetCol()-1)]
    - desc = self.grid.GetCellValue(event.GetRow(), event.GetCol()-2)
    - if hasattr(self, "dialog"):
    - self.dialog.SetOptions(options, desc)
    - answer = self.dialog.ShowModal()
    - #self.dialog.SetOptions(options, desc)
    - else:
    - self.dialog = WampOptionsEditor(self.Parent.Parent, options, desc)
    - answer = self.dialog.ShowModal()
    - opt,OnChange,value,description = self.dialog.GetOptions()
    - if answer == wx.ID_OK:
    - self.grid.SetCellValue(event.GetRow(), event.GetCol(), str(opt))
    - if OnChange:
    - self.grid.SetCellValue(event.GetRow(), event.GetCol()-1, value)
    - self.grid.SetCellValue(event.GetRow(), event.GetCol()-2, description)
    - self.Parent.RefreshModel()
    -
    - else:
    - event.Skip()
    -VariablesTable.LeftClick = LeftClick
    -
    -def VariablesEditorSetCollSize(self):
    - ColSizes = [20, 150] + [130] * (len(self.VariablesDefaultValue) - 2) + [300]
    - for col in range(self.Table.GetNumberCols()):
    - self.VariablesGrid.SetColSize(col, ColSizes[col])
    -VariablesEditor.VariablesEditorSetCollSize = VariablesEditorSetCollSize
    -
    -def _updateColAttrs(self, grid):
    - """
    - wxGrid -> update the column attributes to add the
    - appropriate renderer given the column name.
    -
    - Otherwise default to the default renderer.
    - """
    - typelist = None
    - accesslist = None
    - self.grid = grid
    - for row in range(self.GetNumberRows()):
    - for col in range(self.GetNumberCols()):
    - editor = None
    - renderer = None
    - colname = self.GetColLabelValue(col, False)
    -
    - if colname in ["Name", "Initial", "Description", "OnChange"]:
    - editor = wx.grid.GridCellTextEditor()
    - elif colname == "Class":
    - editor = wx.grid.GridCellChoiceEditor()
    - editor.SetParameters("input,memory,output")
    - elif colname == "Type":
    - pass
    - else:
    - grid.SetReadOnly(row, col, True)
    -
    - grid.SetCellEditor(row, col, editor)
    - grid.SetCellRenderer(row, col, renderer)
    -
    - grid.SetCellBackgroundColour(row, col, wx.WHITE)
    -
    - self.grid.SetRowMinimalHeight
    - # updated column width, with function VariablesEditorSetCollSize added in VariablesEditor class
    - self.Parent.VariablesEditorSetCollSize()
    - # added left click option on grid, with function LeftClick added in VariablesTable class
    - self.grid.Bind(wx.grid.EVT_GRID_CELL_LEFT_DCLICK, self.LeftClick)
    -VariablesTable._updateColAttrs = _updateColAttrs
    -
    if __name__ == '__main__':
    lpcmanager = LPCManagerLauncher()