Commit 448f330e9ad7c72e34d1ec6fb89d8ecb0fcad24b
1 parent
f99e6899
Exists in
master
and in
6 other branches
ENH: Created State's to ToolBar
Showing
1 changed file
with
27 additions
and
8 deletions
Show diff stats
invesalius/gui/frame.py
... | ... | @@ -369,22 +369,41 @@ 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,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) | |
372 | + self.AddLabelTool(1, "Zoom in image", BMP_ZOOM_IN, kind = wx.ITEM_CHECK) | |
373 | + self.AddLabelTool(2, "Zoom out image", BMP_ZOOM_OUT, kind = wx.ITEM_CHECK) | |
374 | + self.AddLabelTool(3, "Rotate image", BMP_ROTATE, kind = wx.ITEM_CHECK) | |
375 | + self.AddLabelTool(4, "Translate image", BMP_TRANSLATE, kind = wx.ITEM_CHECK) | |
376 | + self.AddLabelTool(5, "Bright and contrast adjustment", BMP_CONTRAST, kind = wx.ITEM_CHECK) | |
377 | 377 | |
378 | 378 | self.Bind(wx.EVT_TOOL, self.OnClick) |
379 | 379 | self.Realize() |
380 | - | |
380 | + | |
381 | + self.states = {1:"Zoom in image", 2:"Zoom out image", | |
382 | + 3:"Rotate image", 4:"Translate image", | |
383 | + 5: "Bright and contrast adjustment"} | |
384 | + | |
381 | 385 | def __bind_events(self): |
382 | 386 | pass |
383 | 387 | |
384 | 388 | def OnClick(self, evt): |
389 | + | |
385 | 390 | id = evt.GetId() |
386 | - print self.GetToolState(id) | |
387 | - self.SetToggle(id, not self.GetToolState(id)) | |
391 | + exist_enable_state = 0 | |
392 | + | |
393 | + for x in xrange(1,6): | |
394 | + #necessary if the usurio enable another state | |
395 | + #with a longer allow, disable the previous state | |
396 | + state = self.GetToolState(x) | |
397 | + if not (x == id) and (state == True): | |
398 | + self.ToggleTool(x, False) | |
399 | + elif(state == True) and (id == x): | |
400 | + ps.Publisher().sendMessage(self.states[id]) | |
401 | + exist_enable_state = 1 | |
402 | + | |
403 | + #Not exist's tool enbled, change to default state | |
404 | + if not (exist_enable_state): | |
405 | + print "Default State" | |
406 | + | |
388 | 407 | evt.Skip() |
389 | 408 | |
390 | 409 | class LayoutToolBar(wx.ToolBar): | ... | ... |