Commit 9158c82b1b23089b039f777b2885f20e898a970d
1 parent
aa1e90e2
Exists in
master
and in
6 other branches
ENH: Tools in toolbar
Showing
1 changed file
with
39 additions
and
12 deletions
Show diff stats
invesalius/gui/frame.py
@@ -46,6 +46,9 @@ SLICE_TOOLS = [ID_SLICE_SCROLL, ID_CROSS] = [wx.NewId() for number in range(2)] | @@ -46,6 +46,9 @@ SLICE_TOOLS = [ID_SLICE_SCROLL, ID_CROSS] = [wx.NewId() for number in range(2)] | ||
46 | SLICE_MODE_BY_ID = {ID_SLICE_SCROLL: const.MODE_SLICE_SCROLL, | 46 | SLICE_MODE_BY_ID = {ID_SLICE_SCROLL: const.MODE_SLICE_SCROLL, |
47 | ID_CROSS: const.MODE_SLICE_CROSS} | 47 | ID_CROSS: const.MODE_SLICE_CROSS} |
48 | 48 | ||
49 | +# Layout toolbar | ||
50 | +VIEW_TOOLS = [ID_LAYOUT, ID_TEXT] = [wx.NewId() for number in range(2)] | ||
51 | + | ||
49 | class Frame(wx.Frame): | 52 | class Frame(wx.Frame): |
50 | def __init__(self, prnt): | 53 | def __init__(self, prnt): |
51 | wx.Frame.__init__(self, id=-1, name='', parent=prnt, | 54 | wx.Frame.__init__(self, id=-1, name='', parent=prnt, |
@@ -609,11 +612,9 @@ class SliceToolBar(wx.ToolBar): | @@ -609,11 +612,9 @@ class SliceToolBar(wx.ToolBar): | ||
609 | BMP_CROSS = wx.Bitmap(os.path.join(const.ICON_DIR, "cross.png"), | 612 | BMP_CROSS = wx.Bitmap(os.path.join(const.ICON_DIR, "cross.png"), |
610 | wx.BITMAP_TYPE_PNG) | 613 | wx.BITMAP_TYPE_PNG) |
611 | 614 | ||
612 | - self.AddLabelTool(ID_SLICE_SCROLL, "Scroll slice", | ||
613 | - BMP_SLICE, kind = wx.ITEM_CHECK) | 615 | + self.AddCheckTool(ID_SLICE_SCROLL, BMP_SLICE) |
614 | 616 | ||
615 | - self.AddLabelTool(ID_CROSS, "Cross", | ||
616 | - BMP_CROSS, kind = wx.ITEM_CHECK) | 617 | + self.AddCheckTool(ID_CROSS, BMP_CROSS) |
617 | 618 | ||
618 | self.Realize() | 619 | self.Realize() |
619 | 620 | ||
@@ -625,7 +626,6 @@ class SliceToolBar(wx.ToolBar): | @@ -625,7 +626,6 @@ class SliceToolBar(wx.ToolBar): | ||
625 | 'Untoggle slice toolbar items') | 626 | 'Untoggle slice toolbar items') |
626 | 627 | ||
627 | def OnClick(self, evt): | 628 | def OnClick(self, evt): |
628 | - | ||
629 | id = evt.GetId() | 629 | id = evt.GetId() |
630 | state = self.GetToolState(id) | 630 | state = self.GetToolState(id) |
631 | 631 | ||
@@ -645,8 +645,10 @@ class SliceToolBar(wx.ToolBar): | @@ -645,8 +645,10 @@ class SliceToolBar(wx.ToolBar): | ||
645 | ps.Publisher().sendMessage('Set cross visibility', 0) | 645 | ps.Publisher().sendMessage('Set cross visibility', 0) |
646 | 646 | ||
647 | for item in SLICE_TOOLS: | 647 | for item in SLICE_TOOLS: |
648 | + print "SLICE_TOOLS" | ||
648 | state = self.GetToolState(item) | 649 | state = self.GetToolState(item) |
649 | if state and (item != id): | 650 | if state and (item != id): |
651 | + print "sim" | ||
650 | self.ToggleTool(item, False) | 652 | self.ToggleTool(item, False) |
651 | 653 | ||
652 | evt.Skip() | 654 | evt.Skip() |
@@ -687,6 +689,8 @@ class LayoutToolBar(wx.ToolBar): | @@ -687,6 +689,8 @@ class LayoutToolBar(wx.ToolBar): | ||
687 | "layout_full_original.gif"), | 689 | "layout_full_original.gif"), |
688 | wx.BITMAP_TYPE_GIF) | 690 | wx.BITMAP_TYPE_GIF) |
689 | 691 | ||
692 | + BMP_TEXT = wx.Bitmap(os.path.join(const.ICON_DIR,"text_original.png")) | ||
693 | + | ||
690 | else: | 694 | else: |
691 | self.BMP_WITHOUT_MENU = wx.Bitmap(os.path.join(const.ICON_DIR, | 695 | self.BMP_WITHOUT_MENU = wx.Bitmap(os.path.join(const.ICON_DIR, |
692 | "layout_data_only.gif"), | 696 | "layout_data_only.gif"), |
@@ -694,24 +698,47 @@ class LayoutToolBar(wx.ToolBar): | @@ -694,24 +698,47 @@ class LayoutToolBar(wx.ToolBar): | ||
694 | self.BMP_WITH_MENU = wx.Bitmap(os.path.join(const.ICON_DIR, | 698 | self.BMP_WITH_MENU = wx.Bitmap(os.path.join(const.ICON_DIR, |
695 | "layout_full.gif"), | 699 | "layout_full.gif"), |
696 | wx.BITMAP_TYPE_GIF) | 700 | wx.BITMAP_TYPE_GIF) |
701 | + BMP_TEXT = wx.Bitmap(os.path.join(const.ICON_DIR,"text_original.png")) | ||
702 | + | ||
697 | 703 | ||
698 | - self.AddLabelTool(101, "",bitmap=self.BMP_WITHOUT_MENU, shortHelp= "Hide task panel") | 704 | + self.AddLabelTool(ID_LAYOUT, "",bitmap=self.BMP_WITHOUT_MENU, shortHelp= "Hide task panel") |
705 | + self.AddCheckTool(ID_TEXT, bitmap=BMP_TEXT, shortHelp= "Hide texts") | ||
699 | 706 | ||
700 | self.Realize() | 707 | self.Realize() |
701 | 708 | ||
702 | def __bind_events_wx(self): | 709 | def __bind_events_wx(self): |
703 | self.Bind(wx.EVT_TOOL, self.OnClick) | 710 | self.Bind(wx.EVT_TOOL, self.OnClick) |
704 | - | ||
705 | - def OnClick(self, evt): | 711 | + |
712 | + def OnClick(self, event): | ||
713 | + id = event.GetId() | ||
714 | + if id == ID_LAYOUT: | ||
715 | + self.OnTask() | ||
716 | + elif id== ID_TEXT: | ||
717 | + self.OnText(event) | ||
718 | + | ||
719 | + | ||
720 | + for item in VIEW_TOOLS: | ||
721 | + state = self.GetToolState(item) | ||
722 | + if state and (item != id): | ||
723 | + self.ToggleTool(item, False) | ||
724 | + | ||
725 | + def OnTask(self): | ||
726 | + | ||
706 | if self.ontool: | 727 | if self.ontool: |
707 | - self.SetToolNormalBitmap(101,self.BMP_WITHOUT_MENU ) | 728 | + self.SetToolNormalBitmap(ID_LAYOUT,self.BMP_WITHOUT_MENU ) |
708 | ps.Publisher().sendMessage('Show task panel') | 729 | ps.Publisher().sendMessage('Show task panel') |
709 | - self.SetToolShortHelp(101,"Hide task panel") | 730 | + self.SetToolShortHelp(ID_LAYOUT,"Hide task panel") |
710 | self.ontool = False | 731 | self.ontool = False |
711 | else: | 732 | else: |
712 | self.bitmap = self.BMP_WITH_MENU | 733 | self.bitmap = self.BMP_WITH_MENU |
713 | - self.SetToolNormalBitmap(101,self.BMP_WITH_MENU) | 734 | + self.SetToolNormalBitmap(ID_LAYOUT,self.BMP_WITH_MENU) |
714 | ps.Publisher().sendMessage('Hide task panel') | 735 | ps.Publisher().sendMessage('Hide task panel') |
715 | - self.SetToolShortHelp(101, "Show task panel") | 736 | + self.SetToolShortHelp(ID_LAYOUT, "Show task panel") |
716 | self.ontool = True | 737 | self.ontool = True |
717 | 738 | ||
739 | + def OnText(self, event): | ||
740 | + if event.IsChecked(): | ||
741 | + print "TODO: Send message so all textactors are shown" | ||
742 | + else: | ||
743 | + print "TODO: Send message so all textactors are hiden" | ||
744 | + |