365 "Description": {"GridCellEditor": wx.grid.GridCellTextEditor, |
365 "Description": {"GridCellEditor": wx.grid.GridCellTextEditor, |
366 "GridCellRenderer": wx.grid.GridCellStringRenderer}, |
366 "GridCellRenderer": wx.grid.GridCellStringRenderer}, |
367 "Engineering Units": {"GridCellEditor": wx.grid.GridCellChoiceEditor, |
367 "Engineering Units": {"GridCellEditor": wx.grid.GridCellChoiceEditor, |
368 # use string renderer with choice editor! |
368 # use string renderer with choice editor! |
369 "GridCellRenderer": wx.grid.GridCellStringRenderer, |
369 "GridCellRenderer": wx.grid.GridCellStringRenderer, |
370 # syntax for GridCellChoiceEditor -> comma separated values |
370 "GridCellEditorConstructorArgs": [x[0] for x in BACnetEngineeringUnits]} |
371 "GridCellEditorParam": ','.join([x[0] for x in BACnetEngineeringUnits])} |
|
372 } |
371 } |
373 |
372 |
374 # obj_properties should be a dictionary, with keys "Object Identifier", |
373 # obj_properties should be a dictionary, with keys "Object Identifier", |
375 # "Object Name", "Description", ... |
374 # "Object Name", "Description", ... |
376 def UpdateVirtualProperties(self, obj_properties): |
375 def UpdateVirtualProperties(self, obj_properties): |
574 for row in range(self.GetNumberRows()): |
573 for row in range(self.GetNumberRows()): |
575 for col in range(self.GetNumberCols()): |
574 for col in range(self.GetNumberCols()): |
576 PropertyName = self.BACnetObjectType.PropertyNames[col] |
575 PropertyName = self.BACnetObjectType.PropertyNames[col] |
577 PropertyConfig = self.BACnetObjectType.PropertyConfig[PropertyName] |
576 PropertyConfig = self.BACnetObjectType.PropertyConfig[PropertyName] |
578 grid.SetReadOnly(row, col, False) |
577 grid.SetReadOnly(row, col, False) |
579 grid.SetCellEditor(row, col, PropertyConfig["GridCellEditor"]()) |
578 GridCellEditorConstructorArgs = \ |
|
579 PropertyConfig["GridCellEditorConstructorArgs"] |
|
580 if "GridCellEditorConstructorArgs" in PropertyConfig else [] |
|
581 grid.SetCellEditor(row, col, PropertyConfig["GridCellEditor"](*GridCellEditorConstructorArgs)) |
580 grid.SetCellRenderer(row, col, PropertyConfig["GridCellRenderer"]()) |
582 grid.SetCellRenderer(row, col, PropertyConfig["GridCellRenderer"]()) |
581 grid.SetCellBackgroundColour(row, col, wx.WHITE) |
583 grid.SetCellBackgroundColour(row, col, wx.WHITE) |
582 grid.SetCellTextColour(row, col, wx.BLACK) |
584 grid.SetCellTextColour(row, col, wx.BLACK) |
583 if "GridCellEditorParam" in PropertyConfig: |
585 if "GridCellEditorParam" in PropertyConfig: |
584 grid.GetCellEditor(row, col).SetParameters( |
586 grid.GetCellEditor(row, col).SetParameters( |
814 ("DownButton", "down", _("Move variable down"))]: |
816 ("DownButton", "down", _("Move variable down"))]: |
815 button = wx.lib.buttons.GenBitmapButton( |
817 button = wx.lib.buttons.GenBitmapButton( |
816 self, bitmap=GetBitmap(bitmap), |
818 self, bitmap=GetBitmap(bitmap), |
817 size=wx.Size(28, 28), |
819 size=wx.Size(28, 28), |
818 style=wx.NO_BORDER) |
820 style=wx.NO_BORDER) |
819 button.SetToolTipString(help) |
821 button.SetToolTip(help) |
820 setattr(self, name, button) |
822 setattr(self, name, button) |
821 controls_sizer.Add(button) |
823 controls_sizer.Add(button) |
822 |
824 |
823 # the variable grid that will populate the bottom row of the main sizer |
825 # the variable grid that will populate the bottom row of the main sizer |
824 panel = self |
826 panel = self |
825 self.VariablesGrid = ObjectGrid(panel, style=wx.VSCROLL) |
827 self.VariablesGrid = ObjectGrid(panel, style=wx.VSCROLL) |
826 # use only to enable drag'n'drop |
828 # use only to enable drag'n'drop |
827 # self.VariablesGrid.SetDropTarget(VariableDropTarget(self)) |
829 # self.VariablesGrid.SetDropTarget(VariableDropTarget(self)) |
828 self.VariablesGrid.Bind( |
830 self.VariablesGrid.Bind( |
829 wx.grid.EVT_GRID_CELL_CHANGE, self.OnVariablesGridCellChange) |
831 wx.grid.EVT_GRID_CELL_CHANGING, self.OnVariablesGridCellChange) |
830 # self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnVariablesGridCellLeftClick) |
832 # self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnVariablesGridCellLeftClick) |
831 # self.VariablesGrid.Bind(wx.grid.EVT_GRID_EDITOR_SHOWN, self.OnVariablesGridEditorShown) |
833 # self.VariablesGrid.Bind(wx.grid.EVT_GRID_EDITOR_SHOWN, self.OnVariablesGridEditorShown) |
832 self.MainSizer.Add(self.VariablesGrid, flag=wx.GROW) |
834 self.MainSizer.Add(self.VariablesGrid, flag=wx.GROW) |
833 |
835 |
834 # Configure the Variables Grid... |
836 # Configure the Variables Grid... |