Commit b6796f8a106bdafd022d4c151c76d42c8f20711d
1 parent
afe704d3
Exists in
master
and in
68 other branches
FIX: Enable/disable items as project is open/close (fix #88)
Showing
5 changed files
with
180 additions
and
9 deletions
Show diff stats
invesalius/constants.py
| @@ -199,10 +199,10 @@ SURFACE_QUALITY = { | @@ -199,10 +199,10 @@ SURFACE_QUALITY = { | ||
| 199 | _("Low"): (3, 2, 0.3000, 0.4), | 199 | _("Low"): (3, 2, 0.3000, 0.4), |
| 200 | _("Medium"): (2, 2, 0.3000, 0.4), | 200 | _("Medium"): (2, 2, 0.3000, 0.4), |
| 201 | _("High"): (0, 1, 0.3000, 0.1), | 201 | _("High"): (0, 1, 0.3000, 0.1), |
| 202 | - _("Optimal *"): (0, 2, 0.3000, 0.4), | ||
| 203 | - _("Custom"): (None, None, None, None)} | 202 | + _("Optimal *"): (0, 2, 0.3000, 0.4)} |
| 204 | DEFAULT_SURFACE_QUALITY = _("Optimal *") | 203 | DEFAULT_SURFACE_QUALITY = _("Optimal *") |
| 205 | 204 | ||
| 205 | + | ||
| 206 | # Surface properties | 206 | # Surface properties |
| 207 | SURFACE_TRANSPARENCY = 0.0 | 207 | SURFACE_TRANSPARENCY = 0.0 |
| 208 | SURFACE_NAME_PATTERN = _("Surface %d") | 208 | SURFACE_NAME_PATTERN = _("Surface %d") |
invesalius/control.py
| @@ -160,14 +160,17 @@ class Controller(): | @@ -160,14 +160,17 @@ class Controller(): | ||
| 160 | if not answer: | 160 | if not answer: |
| 161 | print "Close without changes" | 161 | print "Close without changes" |
| 162 | self.CloseProject() | 162 | self.CloseProject() |
| 163 | + ps.Publisher().sendMessage("Enable state project", False) | ||
| 163 | elif answer == 1: | 164 | elif answer == 1: |
| 164 | self.ShowDialogSaveProject() | 165 | self.ShowDialogSaveProject() |
| 165 | print "Save changes and close" | 166 | print "Save changes and close" |
| 166 | self.CloseProject() | 167 | self.CloseProject() |
| 168 | + ps.Publisher().sendMessage("Enable state project", False) | ||
| 167 | elif answer == -1: | 169 | elif answer == -1: |
| 168 | print "Cancel" | 170 | print "Cancel" |
| 169 | else: | 171 | else: |
| 170 | self.CloseProject() | 172 | self.CloseProject() |
| 173 | + ps.Publisher().sendMessage("Enable state project", False) | ||
| 171 | 174 | ||
| 172 | ########################### | 175 | ########################### |
| 173 | def OnOpenProject(self, pubsub_evt): | 176 | def OnOpenProject(self, pubsub_evt): |
| @@ -193,6 +196,7 @@ class Controller(): | @@ -193,6 +196,7 @@ class Controller(): | ||
| 193 | 196 | ||
| 194 | session = ses.Session() | 197 | session = ses.Session() |
| 195 | session.OpenProject(filepath) | 198 | session.OpenProject(filepath) |
| 199 | + ps.Publisher().sendMessage("Enable state project", True) | ||
| 196 | 200 | ||
| 197 | def SaveProject(self, path=None): | 201 | def SaveProject(self, path=None): |
| 198 | ps.Publisher().sendMessage('Begin busy cursor') | 202 | ps.Publisher().sendMessage('Begin busy cursor') |
| @@ -289,6 +293,7 @@ class Controller(): | @@ -289,6 +293,7 @@ class Controller(): | ||
| 289 | print "No medical images found on given directory" | 293 | print "No medical images found on given directory" |
| 290 | return | 294 | return |
| 291 | self.LoadProject() | 295 | self.LoadProject() |
| 296 | + ps.Publisher().sendMessage("Enable state project", True) | ||
| 292 | 297 | ||
| 293 | def LoadProject(self): | 298 | def LoadProject(self): |
| 294 | proj = prj.Project() | 299 | proj = prj.Project() |
| @@ -361,6 +366,7 @@ class Controller(): | @@ -361,6 +366,7 @@ class Controller(): | ||
| 361 | imagedata, dicom = self.OpenDicomGroup(group, gui=True) | 366 | imagedata, dicom = self.OpenDicomGroup(group, gui=True) |
| 362 | self.CreateDicomProject(imagedata, dicom) | 367 | self.CreateDicomProject(imagedata, dicom) |
| 363 | self.LoadProject() | 368 | self.LoadProject() |
| 369 | + ps.Publisher().sendMessage("Enable state project", True) | ||
| 364 | 370 | ||
| 365 | def OpenDicomGroup(self, dicom_group, gui=True): | 371 | def OpenDicomGroup(self, dicom_group, gui=True): |
| 366 | 372 |
invesalius/gui/default_tasks.py
| @@ -117,6 +117,8 @@ class LowerTaskPanel(wx.Panel): | @@ -117,6 +117,8 @@ class LowerTaskPanel(wx.Panel): | ||
| 117 | self.GetSize(),fpb.FPB_DEFAULT_STYLE, | 117 | self.GetSize(),fpb.FPB_DEFAULT_STYLE, |
| 118 | fpb.FPB_COLLAPSE_TO_BOTTOM) | 118 | fpb.FPB_COLLAPSE_TO_BOTTOM) |
| 119 | 119 | ||
| 120 | + self.enable_items = [] | ||
| 121 | + | ||
| 120 | sizer = wx.BoxSizer(wx.VERTICAL) | 122 | sizer = wx.BoxSizer(wx.VERTICAL) |
| 121 | sizer.Add(fold_panel, 1, wx.GROW|wx.EXPAND) | 123 | sizer.Add(fold_panel, 1, wx.GROW|wx.EXPAND) |
| 122 | self.SetSizer(sizer) | 124 | self.SetSizer(sizer) |
| @@ -130,6 +132,7 @@ class LowerTaskPanel(wx.Panel): | @@ -130,6 +132,7 @@ class LowerTaskPanel(wx.Panel): | ||
| 130 | foldIcons=image_list) | 132 | foldIcons=image_list) |
| 131 | style = fold_panel.GetCaptionStyle(item) | 133 | style = fold_panel.GetCaptionStyle(item) |
| 132 | col = style.GetFirstColour() | 134 | col = style.GetFirstColour() |
| 135 | + self.enable_items.append(item) | ||
| 133 | 136 | ||
| 134 | fold_panel.AddFoldPanelWindow(item, nb.NotebookPanel(item), Spacing= 0, | 137 | fold_panel.AddFoldPanelWindow(item, nb.NotebookPanel(item), Spacing= 0, |
| 135 | leftSpacing=0, rightSpacing=0) | 138 | leftSpacing=0, rightSpacing=0) |
| @@ -142,11 +145,35 @@ class LowerTaskPanel(wx.Panel): | @@ -142,11 +145,35 @@ class LowerTaskPanel(wx.Panel): | ||
| 142 | # foldIcons=image_list) | 145 | # foldIcons=image_list) |
| 143 | #style = fold_panel.GetCaptionStyle(item) | 146 | #style = fold_panel.GetCaptionStyle(item) |
| 144 | #col = style.GetFirstColour() | 147 | #col = style.GetFirstColour() |
| 148 | + #self.enable_items.append(item) | ||
| 145 | # | 149 | # |
| 146 | #fold_panel.AddFoldPanelWindow(item, tools.TaskPanel(item), Spacing= 0, | 150 | #fold_panel.AddFoldPanelWindow(item, tools.TaskPanel(item), Spacing= 0, |
| 147 | # leftSpacing=0, rightSpacing=0) | 151 | # leftSpacing=0, rightSpacing=0) |
| 148 | #fold_panel.Expand(fold_panel.GetFoldPanel(1)) | 152 | #fold_panel.Expand(fold_panel.GetFoldPanel(1)) |
| 149 | 153 | ||
| 154 | + self.SetStateProjectClose() | ||
| 155 | + self.__bind_events() | ||
| 156 | + | ||
| 157 | + | ||
| 158 | + def __bind_events(self): | ||
| 159 | + ps.Publisher().subscribe(self.OnEnableState, "Enable state project") | ||
| 160 | + | ||
| 161 | + def OnEnableState(self, pubsub_evt): | ||
| 162 | + state = pubsub_evt.data | ||
| 163 | + if state: | ||
| 164 | + self.SetStateProjectOpen() | ||
| 165 | + else: | ||
| 166 | + self.SetStateProjectClose() | ||
| 167 | + | ||
| 168 | + def SetStateProjectClose(self): | ||
| 169 | + for item in self.enable_items: | ||
| 170 | + item.Disable() | ||
| 171 | + | ||
| 172 | + def SetStateProjectOpen(self): | ||
| 173 | + for item in self.enable_items: | ||
| 174 | + item.Enable() | ||
| 175 | + | ||
| 176 | + | ||
| 150 | # Upper fold panel | 177 | # Upper fold panel |
| 151 | class UpperTaskPanel(wx.Panel): | 178 | class UpperTaskPanel(wx.Panel): |
| 152 | def __init__(self, parent): | 179 | def __init__(self, parent): |
| @@ -169,6 +196,9 @@ class UpperTaskPanel(wx.Panel): | @@ -169,6 +196,9 @@ class UpperTaskPanel(wx.Panel): | ||
| 169 | image_list.Add(GetExpandedIconBitmap()) | 196 | image_list.Add(GetExpandedIconBitmap()) |
| 170 | image_list.Add(GetCollapsedIconBitmap()) | 197 | image_list.Add(GetCollapsedIconBitmap()) |
| 171 | 198 | ||
| 199 | + | ||
| 200 | + self.enable_items = [] | ||
| 201 | + | ||
| 172 | # Fold 1 - Import | 202 | # Fold 1 - Import |
| 173 | 203 | ||
| 174 | item = fold_panel.AddFoldPanel(_("1. InVesalius start"), collapsed=True, | 204 | item = fold_panel.AddFoldPanel(_("1. InVesalius start"), collapsed=True, |
| @@ -186,6 +216,10 @@ class UpperTaskPanel(wx.Panel): | @@ -186,6 +216,10 @@ class UpperTaskPanel(wx.Panel): | ||
| 186 | 216 | ||
| 187 | item = fold_panel.AddFoldPanel(_("2. Select region of interest"), | 217 | item = fold_panel.AddFoldPanel(_("2. Select region of interest"), |
| 188 | collapsed=True, foldIcons=image_list) | 218 | collapsed=True, foldIcons=image_list) |
| 219 | + | ||
| 220 | + | ||
| 221 | + self.enable_items.append(item) | ||
| 222 | + | ||
| 189 | style = fold_panel.GetCaptionStyle(item) | 223 | style = fold_panel.GetCaptionStyle(item) |
| 190 | col = style.GetFirstColour() | 224 | col = style.GetFirstColour() |
| 191 | slice_panel = slice_.TaskPanel(item) | 225 | slice_panel = slice_.TaskPanel(item) |
| @@ -210,21 +244,44 @@ class UpperTaskPanel(wx.Panel): | @@ -210,21 +244,44 @@ class UpperTaskPanel(wx.Panel): | ||
| 210 | Spacing= 0, leftSpacing=0, rightSpacing=0) | 244 | Spacing= 0, leftSpacing=0, rightSpacing=0) |
| 211 | #fold_panel.Expand(fold_panel.GetFoldPanel(2)) | 245 | #fold_panel.Expand(fold_panel.GetFoldPanel(2)) |
| 212 | 246 | ||
| 247 | + self.enable_items.append(item) | ||
| 248 | + | ||
| 249 | + | ||
| 213 | # Fold 4 | 250 | # Fold 4 |
| 214 | # Export volume | 251 | # Export volume |
| 215 | item = fold_panel.AddFoldPanel(_("4. Export data"), collapsed=True, | 252 | item = fold_panel.AddFoldPanel(_("4. Export data"), collapsed=True, |
| 216 | foldIcons=image_list) | 253 | foldIcons=image_list) |
| 217 | style = fold_panel.GetCaptionStyle(item) | 254 | style = fold_panel.GetCaptionStyle(item) |
| 218 | col = style.GetFirstColour() | 255 | col = style.GetFirstColour() |
| 219 | - | 256 | + self.enable_items.append(item) |
| 257 | + | ||
| 220 | fold_panel.AddFoldPanelWindow(item, exporter.TaskPanel(item), | 258 | fold_panel.AddFoldPanelWindow(item, exporter.TaskPanel(item), |
| 221 | Spacing= 0, leftSpacing=0, rightSpacing=0) | 259 | Spacing= 0, leftSpacing=0, rightSpacing=0) |
| 222 | 260 | ||
| 223 | self.fold_panel = fold_panel | 261 | self.fold_panel = fold_panel |
| 224 | - self.__bind_evt() | ||
| 225 | 262 | ||
| 226 | - def __bind_evt(self): | 263 | + self.SetStateProjectClose() |
| 264 | + self.__bind_events() | ||
| 265 | + | ||
| 266 | + | ||
| 267 | + def __bind_events(self): | ||
| 227 | self.fold_panel.Bind(fpb.EVT_CAPTIONBAR, self.OnFoldPressCaption) | 268 | self.fold_panel.Bind(fpb.EVT_CAPTIONBAR, self.OnFoldPressCaption) |
| 269 | + ps.Publisher().subscribe(self.OnEnableState, "Enable state project") | ||
| 270 | + | ||
| 271 | + def OnEnableState(self, pubsub_evt): | ||
| 272 | + state = pubsub_evt.data | ||
| 273 | + if state: | ||
| 274 | + self.SetStateProjectOpen() | ||
| 275 | + else: | ||
| 276 | + self.SetStateProjectClose() | ||
| 277 | + | ||
| 278 | + def SetStateProjectClose(self): | ||
| 279 | + for item in self.enable_items: | ||
| 280 | + item.Disable() | ||
| 281 | + | ||
| 282 | + def SetStateProjectOpen(self): | ||
| 283 | + for item in self.enable_items: | ||
| 284 | + item.Enable() | ||
| 228 | 285 | ||
| 229 | def OnFoldPressCaption(self, evt): | 286 | def OnFoldPressCaption(self, evt): |
| 230 | id = evt.GetTag().GetId() | 287 | id = evt.GetTag().GetId() |
invesalius/gui/frame.py
| @@ -376,12 +376,37 @@ class MenuBar(wx.MenuBar): | @@ -376,12 +376,37 @@ class MenuBar(wx.MenuBar): | ||
| 376 | #self.Append(options_menu, "Options") | 376 | #self.Append(options_menu, "Options") |
| 377 | self.Append(help_menu, _("Help")) | 377 | self.Append(help_menu, _("Help")) |
| 378 | 378 | ||
| 379 | + | ||
| 380 | + self.enable_items = [const.ID_PROJECT_SAVE, const.ID_PROJECT_SAVE_AS, | ||
| 381 | + const.ID_PROJECT_CLOSE] | ||
| 382 | + | ||
| 383 | + self.SetStateProjectClose() | ||
| 384 | + | ||
| 385 | + def OnEnableState(self, pubsub_evt): | ||
| 386 | + print "----- OnEnableState" | ||
| 387 | + state = pubsub_evt.data | ||
| 388 | + print "state", state | ||
| 389 | + if state: | ||
| 390 | + self.SetStateProjectOpen() | ||
| 391 | + else: | ||
| 392 | + self.SetStateProjectClose() | ||
| 393 | + | ||
| 394 | + | ||
| 395 | + def SetStateProjectOpen(self): | ||
| 396 | + for item in self.enable_items: | ||
| 397 | + self.Enable(item, True) | ||
| 398 | + | ||
| 399 | + def SetStateProjectClose(self): | ||
| 400 | + for item in self.enable_items: | ||
| 401 | + self.Enable(item, False) | ||
| 402 | + | ||
| 379 | def __bind_events(self): | 403 | def __bind_events(self): |
| 380 | # TODO: in future, possibly when wxPython 2.9 is available, | 404 | # TODO: in future, possibly when wxPython 2.9 is available, |
| 381 | # events should be binded directly from wx.Menu / wx.MenuBar | 405 | # events should be binded directly from wx.Menu / wx.MenuBar |
| 382 | # message "Binding events of wx.MenuBar" on [wxpython-users] | 406 | # message "Binding events of wx.MenuBar" on [wxpython-users] |
| 383 | # mail list in Oct 20 2008 | 407 | # mail list in Oct 20 2008 |
| 384 | - pass | 408 | + ps.Publisher().subscribe(self.OnEnableState, "Enable state project") |
| 409 | + | ||
| 385 | 410 | ||
| 386 | # ------------------------------------------------------------------ | 411 | # ------------------------------------------------------------------ |
| 387 | class ProgressBar(wx.Gauge): | 412 | class ProgressBar(wx.Gauge): |
| @@ -480,7 +505,6 @@ class ProjectToolBar(wx.ToolBar): | @@ -480,7 +505,6 @@ class ProjectToolBar(wx.ToolBar): | ||
| 480 | self.SetToolBitmapSize(wx.Size(32,32)) | 505 | self.SetToolBitmapSize(wx.Size(32,32)) |
| 481 | 506 | ||
| 482 | self.parent = parent | 507 | self.parent = parent |
| 483 | - | ||
| 484 | self.__init_items() | 508 | self.__init_items() |
| 485 | self.__bind_events() | 509 | self.__bind_events() |
| 486 | 510 | ||
| @@ -540,11 +564,29 @@ class ProjectToolBar(wx.ToolBar): | @@ -540,11 +564,29 @@ class ProjectToolBar(wx.ToolBar): | ||
| 540 | #self.AddLabelTool(const.ID_PRINT_SCREENSHOT, | 564 | #self.AddLabelTool(const.ID_PRINT_SCREENSHOT, |
| 541 | # "Print medical image...", | 565 | # "Print medical image...", |
| 542 | # BMP_PRINT) | 566 | # BMP_PRINT) |
| 567 | + self.enable_items = [const.ID_PROJECT_SAVE] | ||
| 543 | 568 | ||
| 544 | self.Realize() | 569 | self.Realize() |
| 570 | + self.SetStateProjectClose() | ||
| 571 | + | ||
| 572 | + def SetStateProjectOpen(self): | ||
| 573 | + for tool in self.enable_items: | ||
| 574 | + self.EnableTool(tool, True) | ||
| 575 | + | ||
| 576 | + def SetStateProjectClose(self): | ||
| 577 | + for tool in self.enable_items: | ||
| 578 | + self.EnableTool(tool, False) | ||
| 579 | + | ||
| 580 | + def OnEnableState(self, pubsub_evt): | ||
| 581 | + state = pubsub_evt.data | ||
| 582 | + if state: | ||
| 583 | + self.SetStateProjectOpen() | ||
| 584 | + else: | ||
| 585 | + self.SetStateProjectClose() | ||
| 545 | 586 | ||
| 546 | def __bind_events(self): | 587 | def __bind_events(self): |
| 547 | - pass | 588 | + ps.Publisher().subscribe(self.OnEnableState, "Enable state project") |
| 589 | + | ||
| 548 | #self.Bind(wx.EVT_TOOL, self.OnToolSave, id=const.ID_PROJECT_SAVE) | 590 | #self.Bind(wx.EVT_TOOL, self.OnToolSave, id=const.ID_PROJECT_SAVE) |
| 549 | #self.Bind(wx.EVT_TOOL, self.OnToolOpen, id=const.ID_PROJECT_OPEN) | 591 | #self.Bind(wx.EVT_TOOL, self.OnToolOpen, id=const.ID_PROJECT_OPEN) |
| 550 | #self.Bind(wx.EVT_TOOL, self.OnToolImport, id=const.ID_DICOM_IMPORT) | 592 | #self.Bind(wx.EVT_TOOL, self.OnToolImport, id=const.ID_DICOM_IMPORT) |
| @@ -647,7 +689,30 @@ class ObjectToolBar(wx.ToolBar): | @@ -647,7 +689,30 @@ class ObjectToolBar(wx.ToolBar): | ||
| 647 | self.AddLabelTool(const.STATE_WL, | 689 | self.AddLabelTool(const.STATE_WL, |
| 648 | _("Window and Level"), BMP_CONTRAST, | 690 | _("Window and Level"), BMP_CONTRAST, |
| 649 | kind = wx.ITEM_CHECK) | 691 | kind = wx.ITEM_CHECK) |
| 692 | + | ||
| 693 | + self.enable_items = [const.STATE_WL, const.STATE_PAN, const.STATE_SPIN, | ||
| 694 | + const.STATE_ZOOM_SL, const.STATE_ZOOM,] | ||
| 695 | + | ||
| 650 | self.Realize() | 696 | self.Realize() |
| 697 | + self.SetStateProjectClose() | ||
| 698 | + | ||
| 699 | + | ||
| 700 | + def OnEnableState(self, pubsub_evt): | ||
| 701 | + state = pubsub_evt.data | ||
| 702 | + if state: | ||
| 703 | + self.SetStateProjectOpen() | ||
| 704 | + else: | ||
| 705 | + self.SetStateProjectClose() | ||
| 706 | + | ||
| 707 | + | ||
| 708 | + | ||
| 709 | + def SetStateProjectOpen(self): | ||
| 710 | + for tool in self.enable_items: | ||
| 711 | + self.EnableTool(tool, True) | ||
| 712 | + | ||
| 713 | + def SetStateProjectClose(self): | ||
| 714 | + for tool in self.enable_items: | ||
| 715 | + self.EnableTool(tool, False) | ||
| 651 | 716 | ||
| 652 | 717 | ||
| 653 | def __bind_events_wx(self): | 718 | def __bind_events_wx(self): |
| @@ -656,6 +721,8 @@ class ObjectToolBar(wx.ToolBar): | @@ -656,6 +721,8 @@ class ObjectToolBar(wx.ToolBar): | ||
| 656 | def __bind_events(self): | 721 | def __bind_events(self): |
| 657 | ps.Publisher().subscribe(self.UntoggleAllItems, | 722 | ps.Publisher().subscribe(self.UntoggleAllItems, |
| 658 | 'Untoggle object toolbar items') | 723 | 'Untoggle object toolbar items') |
| 724 | + ps.Publisher().subscribe(self.OnEnableState, "Enable state project") | ||
| 725 | + | ||
| 659 | 726 | ||
| 660 | def OnToggle(self, evt): | 727 | def OnToggle(self, evt): |
| 661 | id = evt.GetId() | 728 | id = evt.GetId() |
| @@ -714,14 +781,33 @@ class SliceToolBar(wx.ToolBar): | @@ -714,14 +781,33 @@ class SliceToolBar(wx.ToolBar): | ||
| 714 | self.AddCheckTool(const.SLICE_STATE_SCROLL, BMP_SLICE) | 781 | self.AddCheckTool(const.SLICE_STATE_SCROLL, BMP_SLICE) |
| 715 | self.AddCheckTool(const.SLICE_STATE_CROSS, BMP_CROSS) | 782 | self.AddCheckTool(const.SLICE_STATE_CROSS, BMP_CROSS) |
| 716 | 783 | ||
| 784 | + self.enable_items = [const.SLICE_STATE_SCROLL, const.SLICE_STATE_CROSS,] | ||
| 717 | self.Realize() | 785 | self.Realize() |
| 786 | + self.SetStateProjectClose() | ||
| 787 | + | ||
| 788 | + def SetStateProjectOpen(self): | ||
| 789 | + for tool in self.enable_items: | ||
| 790 | + self.EnableTool(tool, True) | ||
| 718 | 791 | ||
| 792 | + def SetStateProjectClose(self): | ||
| 793 | + for tool in self.enable_items: | ||
| 794 | + self.EnableTool(tool, False) | ||
| 795 | + | ||
| 719 | def __bind_events_wx(self): | 796 | def __bind_events_wx(self): |
| 720 | self.Bind(wx.EVT_TOOL, self.OnClick) | 797 | self.Bind(wx.EVT_TOOL, self.OnClick) |
| 721 | 798 | ||
| 722 | def __bind_events(self): | 799 | def __bind_events(self): |
| 723 | ps.Publisher().subscribe(self.UntoggleAllItem, | 800 | ps.Publisher().subscribe(self.UntoggleAllItem, |
| 724 | 'Untoggle slice toolbar items') | 801 | 'Untoggle slice toolbar items') |
| 802 | + ps.Publisher().subscribe(self.OnEnableState, "Enable state project") | ||
| 803 | + | ||
| 804 | + def OnEnableState(self, pubsub_evt): | ||
| 805 | + state = pubsub_evt.data | ||
| 806 | + if state: | ||
| 807 | + self.SetStateProjectOpen() | ||
| 808 | + else: | ||
| 809 | + self.SetStateProjectClose() | ||
| 810 | + | ||
| 725 | 811 | ||
| 726 | def OnClick(self, evt): | 812 | def OnClick(self, evt): |
| 727 | id = evt.GetId() | 813 | id = evt.GetId() |
| @@ -793,7 +879,19 @@ class LayoutToolBar(wx.ToolBar): | @@ -793,7 +879,19 @@ class LayoutToolBar(wx.ToolBar): | ||
| 793 | self.AddCheckTool(ID_TEXT, bitmap=BMP_TEXT, shortHelp= "Hide texts") | 879 | self.AddCheckTool(ID_TEXT, bitmap=BMP_TEXT, shortHelp= "Hide texts") |
| 794 | self.ToggleTool(ID_TEXT, True) | 880 | self.ToggleTool(ID_TEXT, True) |
| 795 | 881 | ||
| 882 | + self.enable_items = [ID_TEXT] | ||
| 796 | self.Realize() | 883 | self.Realize() |
| 884 | + self.SetStateProjectClose() | ||
| 885 | + | ||
| 886 | + def SetStateProjectOpen(self): | ||
| 887 | + for tool in self.enable_items: | ||
| 888 | + self.EnableTool(tool, True) | ||
| 889 | + | ||
| 890 | + def SetStateProjectClose(self): | ||
| 891 | + for tool in self.enable_items: | ||
| 892 | + self.EnableTool(tool, False) | ||
| 893 | + | ||
| 894 | + | ||
| 797 | 895 | ||
| 798 | def __bind_events(self): | 896 | def __bind_events(self): |
| 799 | ps.Publisher().subscribe(self.SetLayoutButtonOnlyData, | 897 | ps.Publisher().subscribe(self.SetLayoutButtonOnlyData, |
| @@ -801,6 +899,17 @@ class LayoutToolBar(wx.ToolBar): | @@ -801,6 +899,17 @@ class LayoutToolBar(wx.ToolBar): | ||
| 801 | ps.Publisher().subscribe(self.SetLayoutButtonFull, | 899 | ps.Publisher().subscribe(self.SetLayoutButtonFull, |
| 802 | "Set layout button full") | 900 | "Set layout button full") |
| 803 | 901 | ||
| 902 | + ps.Publisher().subscribe(self.OnEnableState, "Enable state project") | ||
| 903 | + | ||
| 904 | + def OnEnableState(self, pubsub_evt): | ||
| 905 | + state = pubsub_evt.data | ||
| 906 | + if state: | ||
| 907 | + self.SetStateProjectOpen() | ||
| 908 | + else: | ||
| 909 | + self.SetStateProjectClose() | ||
| 910 | + | ||
| 911 | + | ||
| 912 | + | ||
| 804 | def __bind_events_wx(self): | 913 | def __bind_events_wx(self): |
| 805 | self.Bind(wx.EVT_TOOL, self.OnClick) | 914 | self.Bind(wx.EVT_TOOL, self.OnClick) |
| 806 | 915 |
invesalius/invesalius.py
| @@ -184,7 +184,6 @@ def print_events(data): | @@ -184,7 +184,6 @@ def print_events(data): | ||
| 184 | def main(): | 184 | def main(): |
| 185 | application = InVesalius(0) | 185 | application = InVesalius(0) |
| 186 | parse_comand_line() | 186 | parse_comand_line() |
| 187 | - #application.ShowFrame() | ||
| 188 | application.MainLoop() | 187 | application.MainLoop() |
| 189 | 188 | ||
| 190 | if __name__ == '__main__': | 189 | if __name__ == '__main__': |