83 editor = None |
83 editor = None |
84 renderer = None |
84 renderer = None |
85 readonly = False |
85 readonly = False |
86 colname = self.GetColLabelValue(col, False) |
86 colname = self.GetColLabelValue(col, False) |
87 if colname == "Qualifier": |
87 if colname == "Qualifier": |
88 editor = wx.grid.GridCellChoiceEditor() |
88 editor = wx.grid.GridCellChoiceEditor(self.Parent.QualifierList) |
89 editor.SetParameters(self.Parent.QualifierList) |
|
90 if colname == "Duration": |
89 if colname == "Duration": |
91 editor = wx.grid.GridCellTextEditor() |
90 editor = wx.grid.GridCellTextEditor() |
92 renderer = wx.grid.GridCellStringRenderer() |
91 renderer = wx.grid.GridCellStringRenderer() |
93 readonly = not self.Parent.DurationList[self.data[row].qualifier] |
92 readonly = not self.Parent.DurationList[self.data[row].qualifier] |
94 elif colname == "Type": |
93 elif colname == "Type": |
95 editor = wx.grid.GridCellChoiceEditor() |
94 editor = wx.grid.GridCellChoiceEditor(self.Parent.TypeList) |
96 editor.SetParameters(self.Parent.TypeList) |
|
97 elif colname == "Value": |
95 elif colname == "Value": |
98 value_type = self.data[row].type |
96 value_type = self.data[row].type |
99 if value_type == "Action": |
97 if value_type == "Action": |
100 editor = wx.grid.GridCellChoiceEditor() |
98 editor = wx.grid.GridCellChoiceEditor(self.Parent.ActionList) |
101 editor.SetParameters(self.Parent.ActionList) |
|
102 elif value_type == "Variable": |
99 elif value_type == "Variable": |
103 editor = wx.grid.GridCellChoiceEditor() |
100 editor = wx.grid.GridCellChoiceEditor(self.Parent.VariableList) |
104 editor.SetParameters(self.Parent.VariableList) |
|
105 elif value_type == "Inline": |
101 elif value_type == "Inline": |
106 editor = wx.grid.GridCellTextEditor() |
102 editor = wx.grid.GridCellTextEditor() |
107 renderer = wx.grid.GridCellStringRenderer() |
103 renderer = wx.grid.GridCellStringRenderer() |
108 elif colname == "Indicator": |
104 elif colname == "Indicator": |
109 editor = wx.grid.GridCellChoiceEditor() |
105 editor = wx.grid.GridCellChoiceEditor(self.Parent.VariableList) |
110 editor.SetParameters(self.Parent.VariableList) |
|
111 |
106 |
112 grid.SetCellEditor(row, col, editor) |
107 grid.SetCellEditor(row, col, editor) |
113 grid.SetCellRenderer(row, col, renderer) |
108 grid.SetCellRenderer(row, col, renderer) |
114 grid.SetReadOnly(row, col, readonly) |
109 grid.SetReadOnly(row, col, readonly) |
115 |
110 |
131 main_sizer.AddGrowableRow(1) |
126 main_sizer.AddGrowableRow(1) |
132 |
127 |
133 top_sizer = wx.FlexGridSizer(cols=5, hgap=5, rows=1, vgap=0) |
128 top_sizer = wx.FlexGridSizer(cols=5, hgap=5, rows=1, vgap=0) |
134 top_sizer.AddGrowableCol(0) |
129 top_sizer.AddGrowableCol(0) |
135 top_sizer.AddGrowableRow(0) |
130 top_sizer.AddGrowableRow(0) |
136 main_sizer.AddSizer(top_sizer, border=20, |
131 main_sizer.Add(top_sizer, border=20, |
137 flag=wx.GROW | wx.TOP | wx.LEFT | wx.RIGHT) |
132 flag=wx.GROW | wx.TOP | wx.LEFT | wx.RIGHT) |
138 |
133 |
139 actions_label = wx.StaticText(self, label=_('Actions:')) |
134 actions_label = wx.StaticText(self, label=_('Actions:')) |
140 top_sizer.AddWindow(actions_label, flag=wx.ALIGN_BOTTOM) |
135 top_sizer.Add(actions_label, flag=wx.ALIGN_BOTTOM) |
141 |
136 |
142 for name, bitmap, help in [ |
137 for name, bitmap, help in [ |
143 ("AddButton", "add_element", _("Add action")), |
138 ("AddButton", "add_element", _("Add action")), |
144 ("DeleteButton", "remove_element", _("Remove action")), |
139 ("DeleteButton", "remove_element", _("Remove action")), |
145 ("UpButton", "up", _("Move action up")), |
140 ("UpButton", "up", _("Move action up")), |
146 ("DownButton", "down", _("Move action down"))]: |
141 ("DownButton", "down", _("Move action down"))]: |
147 button = wx.lib.buttons.GenBitmapButton( |
142 button = wx.lib.buttons.GenBitmapButton( |
148 self, bitmap=GetBitmap(bitmap), |
143 self, bitmap=GetBitmap(bitmap), |
149 size=wx.Size(28, 28), style=wx.NO_BORDER) |
144 size=wx.Size(28, 28), style=wx.NO_BORDER) |
150 button.SetToolTipString(help) |
145 button.SetToolTip(help) |
151 setattr(self, name, button) |
146 setattr(self, name, button) |
152 top_sizer.AddWindow(button) |
147 top_sizer.Add(button) |
153 |
148 |
154 self.ActionsGrid = CustomGrid(self, size=wx.Size(-1, 250), style=wx.VSCROLL) |
149 self.ActionsGrid = CustomGrid(self, size=wx.Size(-1, 250), style=wx.VSCROLL) |
155 self.ActionsGrid.DisableDragGridSize() |
150 self.ActionsGrid.DisableDragGridSize() |
156 self.ActionsGrid.EnableScrolling(False, True) |
151 self.ActionsGrid.EnableScrolling(False, True) |
157 self.ActionsGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, |
152 self.ActionsGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGING, |
158 self.OnActionsGridCellChange) |
153 self.OnActionsGridCellChange) |
159 main_sizer.AddSizer(self.ActionsGrid, border=20, |
154 main_sizer.Add(self.ActionsGrid, border=20, |
160 flag=wx.GROW | wx.LEFT | wx.RIGHT) |
155 flag=wx.GROW | wx.LEFT | wx.RIGHT) |
161 |
156 |
162 button_sizer = self.CreateButtonSizer(wx.OK | wx.CANCEL | wx.CENTRE) |
157 button_sizer = self.CreateButtonSizer(wx.OK | wx.CANCEL | wx.CENTRE) |
163 self.Bind(wx.EVT_BUTTON, self.OnOK, button_sizer.GetAffirmativeButton()) |
158 self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetAffirmativeId()) |
164 main_sizer.AddSizer(button_sizer, border=20, |
159 main_sizer.Add(button_sizer, border=20, |
165 flag=wx.ALIGN_RIGHT | wx.BOTTOM | wx.LEFT | wx.RIGHT) |
160 flag=wx.ALIGN_RIGHT | wx.BOTTOM | wx.LEFT | wx.RIGHT) |
166 |
161 |
167 self.SetSizer(main_sizer) |
162 self.SetSizer(main_sizer) |
168 |
163 |
169 self.Table = ActionTable(self, [], GetActionTableColnames()) |
164 self.Table = ActionTable(self, [], GetActionTableColnames()) |