21 #You should have received a copy of the GNU General Public |
21 #You should have received a copy of the GNU General Public |
22 #License along with this library; if not, write to the Free Software |
22 #License along with this library; if not, write to the Free Software |
23 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
23 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
24 |
24 |
25 import wx |
25 import wx |
|
26 import wx.lib.buttons |
26 |
27 |
27 from graphics import DebugDataConsumer, DebugViewer |
28 from graphics import DebugDataConsumer, DebugViewer |
28 from controls import CustomGrid, CustomTable |
29 from controls import CustomGrid, CustomTable |
|
30 from utils.BitmapLibrary import GetBitmap |
29 |
31 |
30 def GetDebugVariablesTableColnames(): |
32 def GetDebugVariablesTableColnames(): |
31 _ = lambda x : x |
33 _ = lambda x : x |
32 return [_("Variable"), _("Value")] |
34 return [_("Variable"), _("Value")] |
33 |
35 |
157 dialog.ShowModal() |
159 dialog.ShowModal() |
158 dialog.Destroy() |
160 dialog.Destroy() |
159 |
161 |
160 class DebugVariablePanel(wx.Panel, DebugViewer): |
162 class DebugVariablePanel(wx.Panel, DebugViewer): |
161 |
163 |
162 def __init__(self, parent, window, producer): |
164 def __init__(self, parent, producer): |
163 wx.Panel.__init__(self, parent, style=wx.TAB_TRAVERSAL) |
165 wx.Panel.__init__(self, parent, style=wx.TAB_TRAVERSAL) |
164 DebugViewer.__init__(self, producer, True) |
166 DebugViewer.__init__(self, producer, True) |
165 |
167 |
166 main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0) |
168 main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0) |
167 main_sizer.AddGrowableCol(0) |
169 main_sizer.AddGrowableCol(0) |
169 |
171 |
170 button_sizer = wx.BoxSizer(wx.HORIZONTAL) |
172 button_sizer = wx.BoxSizer(wx.HORIZONTAL) |
171 main_sizer.AddSizer(button_sizer, border=5, |
173 main_sizer.AddSizer(button_sizer, border=5, |
172 flag=wx.ALIGN_RIGHT|wx.ALL) |
174 flag=wx.ALIGN_RIGHT|wx.ALL) |
173 |
175 |
174 up_button = wx.Button(self, label='^', size=wx.Size(28, 28)) |
176 for name, bitmap, help in [ |
175 button_sizer.AddWindow(up_button, border=5, flag=wx.RIGHT) |
177 ("DeleteButton", "remove_element", _("Remove debug variable")), |
176 |
178 ("UpButton", "up", _("Move debug variable up")), |
177 down_button = wx.Button(self, label='v', size=wx.Size(28, 28)) |
179 ("DownButton", "down", _("Move debug variable down"))]: |
178 button_sizer.AddWindow(down_button, border=5, flag=wx.RIGHT) |
180 button = wx.lib.buttons.GenBitmapButton(self, bitmap=GetBitmap(bitmap), |
179 |
181 size=wx.Size(28, 28), style=wx.NO_BORDER) |
180 delete_button = wx.Button(self, label=_('Delete'), size=wx.DefaultSize) |
182 button.SetToolTipString(help) |
181 button_sizer.AddWindow(delete_button) |
183 setattr(self, name, button) |
|
184 button_sizer.AddWindow(button, border=5, flag=wx.LEFT) |
182 |
185 |
183 self.VariablesGrid = CustomGrid(self, size=wx.Size(0, 150), style=wx.VSCROLL) |
186 self.VariablesGrid = CustomGrid(self, size=wx.Size(0, 150), style=wx.VSCROLL) |
184 self.VariablesGrid.SetDropTarget(DebugVariableDropTarget(self)) |
187 self.VariablesGrid.SetDropTarget(DebugVariableDropTarget(self)) |
185 self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_RIGHT_CLICK, |
188 self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_RIGHT_CLICK, |
186 self.OnVariablesGridCellRightClick) |
189 self.OnVariablesGridCellRightClick) |
190 |
193 |
191 self.HasNewData = False |
194 self.HasNewData = False |
192 |
195 |
193 self.Table = DebugVariableTable(self, [], GetDebugVariablesTableColnames()) |
196 self.Table = DebugVariableTable(self, [], GetDebugVariablesTableColnames()) |
194 self.VariablesGrid.SetTable(self.Table) |
197 self.VariablesGrid.SetTable(self.Table) |
195 self.VariablesGrid.SetButtons({"Delete": delete_button, |
198 self.VariablesGrid.SetButtons({"Delete": self.DeleteButton, |
196 "Up": up_button, |
199 "Up": self.UpButton, |
197 "Down": down_button}) |
200 "Down": self.DownButton}) |
198 |
201 |
199 def _AddVariable(new_row): |
202 def _AddVariable(new_row): |
200 return self.VariablesGrid.GetGridCursorRow() |
203 return self.VariablesGrid.GetGridCursorRow() |
201 setattr(self.VariablesGrid, "_AddRow", _AddVariable) |
204 setattr(self.VariablesGrid, "_AddRow", _AddVariable) |
202 |
205 |