Commit f99e68999cfb29851468e722057a027f4babc015

Authored by Paulo Henrique Junqueira Amorim
1 parent e021cf2c

ADD: Event clicked toolbar

Showing 1 changed file with 38 additions and 31 deletions   Show diff stats
invesalius/gui/frame.py
... ... @@ -60,7 +60,7 @@ class Frame(wx.Frame):
60 60 def __bind_events(self):
61 61 ps.Publisher().subscribe(self.ShowContentPanel, 'Show content panel')
62 62 ps.Publisher().subscribe(self.ShowImportPanel, "Show import panel")
63   -
  63 +
64 64 def __bind_events_wx(self):
65 65 self.Bind(wx.EVT_SIZE, self.OnSize)
66 66  
... ... @@ -86,12 +86,12 @@ class Frame(wx.Frame):
86 86 Hide().Layer(1).MaximizeButton(True).Name("Data").
87 87 Position(1))
88 88  
89   -
  89 +
90 90 aui_manager.AddPane(imp.Panel(self), wx.aui.AuiPaneInfo().
91 91 Name("Import").Centre().Hide().
92 92 Caption("Preview medical data to be reconstructed").
93 93 CaptionVisible(True))
94   -
  94 +
95 95  
96 96 # Add toolbars to manager
97 97  
... ... @@ -102,8 +102,8 @@ class Frame(wx.Frame):
102 102 else:
103 103 t3 = ProjectToolBar(self)
104 104 #t2 = LayoutToolBar(self)
105   - t1 = ObjectToolBar(self)
106   -
  105 + t1 = ObjectToolBar(self)
  106 +
107 107 aui_manager.AddPane(t1, wx.aui.AuiPaneInfo().
108 108 Name("General Features Toolbar").
109 109 ToolbarPane().Top().Floatable(False).
... ... @@ -129,7 +129,7 @@ class Frame(wx.Frame):
129 129 def ShowImportPanel(self, evt_pubsub):
130 130 path = evt_pubsub.data
131 131 ps.Publisher().sendMessage("Load data to import panel", path)
132   -
  132 +
133 133 aui_manager = self.aui_manager
134 134 aui_manager.GetPane("Import").Show(1)
135 135 aui_manager.GetPane("Data").Show(0)
... ... @@ -222,7 +222,7 @@ class ProgressBar(wx.Gauge):
222 222  
223 223 def __bind_events(self):
224 224 ps.Publisher().subscribe(self.Reposition, 'ProgressBar Reposition')
225   -
  225 +
226 226 def UpdateValue(self, value):
227 227 #value = int(math.ceil(evt_pubsub.data[0]))
228 228 self.SetValue(int(value))
... ... @@ -247,25 +247,25 @@ class StatusBar(wx.StatusBar):
247 247 self.SetStatusText("Ready", 0)
248 248 self.SetStatusText("", 1)
249 249 self.SetStatusText("", 2)
250   -
  250 +
251 251 self.progress_bar = ProgressBar(self)
252   -
  252 +
253 253 self.__bind_events()
254   -
  254 +
255 255 def __bind_events(self):
256 256 ps.Publisher().subscribe(self.UpdateStatus, 'Update status in GUI')
257 257 ps.Publisher().subscribe(self.UpdateStatusLabel,
258 258 'Update status text in GUI')
259   -
  259 +
260 260 def UpdateStatus(self, pubsub_evt):
261 261 value, label = pubsub_evt.data
262 262 self.progress_bar.UpdateValue(value)
263 263 self.SetStatusText(label, 0)
264   -
  264 +
265 265 def UpdateStatusLabel(self, pubsub_evt):
266 266 label = pubsub_evt.data
267 267 self.SetStatusText(label, 0)
268   -
  268 +
269 269  
270 270 # ------------------------------------------------------------------------------
271 271  
... ... @@ -300,7 +300,7 @@ class ProjectToolBar(wx.ToolBar):
300 300  
301 301  
302 302 if sys.platform == 'darwin':
303   - BMP_IMPORT = wx.Bitmap("../icons/file_import_original.png",
  303 + BMP_IMPORT = wx.Bitmap("../icons/file_import_original.png",
304 304 wx.BITMAP_TYPE_PNG)
305 305 BMP_NET = wx.Bitmap("../icons/file_from_internet_original.png",
306 306 wx.BITMAP_TYPE_PNG)
... ... @@ -321,7 +321,7 @@ class ProjectToolBar(wx.ToolBar):
321 321 wx.BITMAP_TYPE_PNG)
322 322 BMP_PHOTO = wx.Bitmap("../icons/tool_photo.png",
323 323 wx.BITMAP_TYPE_PNG)
324   -
  324 +
325 325 self.AddLabelTool(ID_FILE_IMPORT, "Import medical image...", BMP_IMPORT)
326 326 self.AddLabelTool(ID_FILE_LOAD_INTERNET, "Load medical image...",
327 327 BMP_NET)
... ... @@ -334,15 +334,15 @@ class ProjectToolBar(wx.ToolBar):
334 334  
335 335 def __bind_events(self):
336 336 pass
337   -
  337 +
338 338 class ObjectToolBar(wx.ToolBar):
339 339 # TODO: what will appear in menubar?
340 340 def __init__(self, parent):
341   - wx.ToolBar.__init__(self, parent, -1, wx.DefaultPosition, wx.DefaultSize,
342   - wx.TB_FLAT|wx.TB_NODIVIDER)
  341 + wx.ToolBar.__init__(self, parent, -1, wx.DefaultPosition, wx.DefaultSize,
  342 + wx.TB_FLAT|wx.TB_NODIVIDER | wx.TB_DOCKABLE)
343 343 if sys.platform == 'darwin':
344 344 self.SetToolBitmapSize(wx.Size(32,32))
345   -
  345 +
346 346 self.parent = parent
347 347 self.__init_items()
348 348 self.__bind_events()
... ... @@ -351,13 +351,13 @@ class ObjectToolBar(wx.ToolBar):
351 351  
352 352  
353 353 if sys.platform == 'darwin':
354   - BMP_ROTATE = wx.Bitmap("../icons/tool_rotate_original.gif",
  354 + BMP_ROTATE = wx.Bitmap("../icons/tool_rotate_original.gif",
355 355 wx.BITMAP_TYPE_GIF)
356   - BMP_TRANSLATE = wx.Bitmap("../icons/tool_translate_original.png",
  356 + BMP_TRANSLATE = wx.Bitmap("../icons/tool_translate_original.png",
357 357 wx.BITMAP_TYPE_PNG)
358   - BMP_ZOOM_IN = wx.Bitmap("../icons/tool_zoom_in_original.png",
  358 + BMP_ZOOM_IN = wx.Bitmap("../icons/tool_zoom_in_original.png",
359 359 wx.BITMAP_TYPE_PNG)
360   - BMP_ZOOM_OUT = wx.Bitmap("../icons/tool_zoom_out_original.png",
  360 + BMP_ZOOM_OUT = wx.Bitmap("../icons/tool_zoom_out_original.png",
361 361 wx.BITMAP_TYPE_PNG)
362 362 BMP_CONTRAST = wx.Bitmap("../icons/tool_contrast.png",
363 363 wx.BITMAP_TYPE_PNG)
... ... @@ -369,24 +369,31 @@ class ObjectToolBar(wx.ToolBar):
369 369 BMP_CONTRAST = wx.Bitmap("../icons/tool_contrast.png", wx.BITMAP_TYPE_PNG)
370 370  
371 371  
372   - self.AddLabelTool(101, "Zoom in image", BMP_ZOOM_IN)
373   - self.AddLabelTool(101, "Zoom out image", BMP_ZOOM_OUT)
374   - self.AddLabelTool(101, "Rotate image", BMP_ROTATE)
375   - self.AddLabelTool(101, "Translate image", BMP_TRANSLATE)
376   - self.AddLabelTool(101, "Bright and contrast adjustment", BMP_CONTRAST)
377   -
  372 + self.AddLabelTool(101, "Zoom in image", BMP_ZOOM_IN,kind = wx.ITEM_RADIO)
  373 + self.AddLabelTool(102, "Zoom out image", BMP_ZOOM_OUT)
  374 + self.AddLabelTool(103, "Rotate image", BMP_ROTATE)
  375 + self.AddLabelTool(104, "Translate image", BMP_TRANSLATE)
  376 + self.AddLabelTool(105, "Bright and contrast adjustment", BMP_CONTRAST)
  377 +
  378 + self.Bind(wx.EVT_TOOL, self.OnClick)
378 379 self.Realize()
379 380  
380 381 def __bind_events(self):
381 382 pass
382 383  
  384 + def OnClick(self, evt):
  385 + id = evt.GetId()
  386 + print self.GetToolState(id)
  387 + self.SetToggle(id, not self.GetToolState(id))
  388 + evt.Skip()
  389 +
383 390 class LayoutToolBar(wx.ToolBar):
384 391 # TODO: what will appear in menubar?
385 392 def __init__(self, parent):
386 393 wx.ToolBar.__init__(self, parent, -1, wx.DefaultPosition, wx.DefaultSize, wx.TB_FLAT|wx.TB_NODIVIDER)
387 394 if sys.platform == 'darwin':
388 395 self.SetToolBitmapSize(wx.Size(32,32))
389   -
  396 +
390 397 self.parent = parent
391 398 self.__init_items()
392 399 self.__bind_events()
... ... @@ -396,7 +403,7 @@ class LayoutToolBar(wx.ToolBar):
396 403 BMP_TRANSLATE = wx.Bitmap("../icons/layout_full_original.gif", wx.BITMAP_TYPE_GIF)
397 404  
398 405 self.AddLabelTool(101, "Rotate image", BMP_ROTATE)
399   - self.AddLabelTool(101, "Translate image", BMP_TRANSLATE)
  406 + self.AddLabelTool(101, "Translate image", BMP_TRANSLATE)
400 407  
401 408 self.Realize()
402 409  
... ...