549 return new_row |
549 return new_row |
550 return row |
550 return row |
551 setattr(self.VariablesGrid, "_MoveRow", _MoveVariable) |
551 setattr(self.VariablesGrid, "_MoveRow", _MoveVariable) |
552 |
552 |
553 def _RefreshButtons(): |
553 def _RefreshButtons(): |
554 table_length = len(self.Table.data) |
554 if self: |
555 row_class = None |
555 table_length = len(self.Table.data) |
556 row_edit = True |
556 row_class = None |
557 row = 0 |
557 row_edit = True |
558 if table_length > 0: |
558 row = 0 |
559 row = self.VariablesGrid.GetGridCursorRow() |
559 if table_length > 0: |
560 row_edit = self.Table.GetValueByName(row, "Edit") |
560 row = self.VariablesGrid.GetGridCursorRow() |
561 if self.PouIsUsed: |
561 row_edit = self.Table.GetValueByName(row, "Edit") |
562 row_class = self.Table.GetValueByName(row, "Class") |
562 if self.PouIsUsed: |
563 self.AddButton.Enable(not self.Debug and (not self.PouIsUsed or self.Filter not in ["Interface", "Input", "Output", "InOut"])) |
563 row_class = self.Table.GetValueByName(row, "Class") |
564 self.DeleteButton.Enable(not self.Debug and (table_length > 0 and row_edit and row_class not in ["Input", "Output", "InOut"])) |
564 self.AddButton.Enable(not self.Debug and (not self.PouIsUsed or self.Filter not in ["Interface", "Input", "Output", "InOut"])) |
565 self.UpButton.Enable(not self.Debug and (table_length > 0 and row > 0 and self.Filter == "All" and row_class not in ["Input", "Output", "InOut"])) |
565 self.DeleteButton.Enable(not self.Debug and (table_length > 0 and row_edit and row_class not in ["Input", "Output", "InOut"])) |
566 self.DownButton.Enable(not self.Debug and (table_length > 0 and row < table_length - 1 and self.Filter == "All" and row_class not in ["Input", "Output", "InOut"])) |
566 self.UpButton.Enable(not self.Debug and (table_length > 0 and row > 0 and self.Filter == "All" and row_class not in ["Input", "Output", "InOut"])) |
|
567 self.DownButton.Enable(not self.Debug and (table_length > 0 and row < table_length - 1 and self.Filter == "All" and row_class not in ["Input", "Output", "InOut"])) |
567 setattr(self.VariablesGrid, "RefreshButtons", _RefreshButtons) |
568 setattr(self.VariablesGrid, "RefreshButtons", _RefreshButtons) |
568 |
569 |
569 self.VariablesGrid.SetRowLabelSize(0) |
570 self.VariablesGrid.SetRowLabelSize(0) |
570 for col in range(self.Table.GetNumberCols()): |
571 for col in range(self.Table.GetNumberCols()): |
571 attr = wx.grid.GridCellAttr() |
572 attr = wx.grid.GridCellAttr() |