Commit 9a6b5311747092b21fe7ff085a7604a442cad3b2
1 parent
4e82c3bd
Exists in
master
and in
6 other branches
ADD: Run folder selection to importation, from menu and toolbar
Showing
4 changed files
with
31 additions
and
17 deletions
Show diff stats
invesalius/constants.py
@@ -271,3 +271,11 @@ IMAGE_TILING = {"1 x 1":(1,1), "1 x 2":(1,2), | @@ -271,3 +271,11 @@ IMAGE_TILING = {"1 x 1":(1,1), "1 x 2":(1,2), | ||
271 | "4 x 5":(4,5), "5 x 4":(5,4)} | 271 | "4 x 5":(4,5), "5 x 4":(5,4)} |
272 | 272 | ||
273 | VTK_WARNING = 0 | 273 | VTK_WARNING = 0 |
274 | + | ||
275 | +#---------------------------------------------------------- | ||
276 | + | ||
277 | +[ID_FILE_IMPORT, ID_FILE_LOAD_INTERNET, ID_FILE_SAVE, ID_FILE_PHOTO, | ||
278 | +ID_FILE_PRINT] = [wx.NewId() for number in range(5)] | ||
279 | + | ||
280 | + | ||
281 | + |
invesalius/gui/frame.py
@@ -30,10 +30,6 @@ import default_tasks as tasks | @@ -30,10 +30,6 @@ import default_tasks as tasks | ||
30 | import default_viewers as viewers | 30 | import default_viewers as viewers |
31 | import import_panel as imp | 31 | import import_panel as imp |
32 | 32 | ||
33 | -# File toolbar | ||
34 | -[ID_FILE_IMPORT, ID_FILE_LOAD_INTERNET, ID_FILE_SAVE, ID_FILE_PHOTO, | ||
35 | -ID_FILE_PRINT] = [wx.NewId() for number in range(5)] | ||
36 | - | ||
37 | # Object toolbar | 33 | # Object toolbar |
38 | OBJ_TOOLS = [ID_ZOOM, ID_ZOOM_SELECT, ID_ROTATE, ID_MOVE, | 34 | OBJ_TOOLS = [ID_ZOOM, ID_ZOOM_SELECT, ID_ROTATE, ID_MOVE, |
39 | ID_CONTRAST] = [wx.NewId() for number in range(5)] | 35 | ID_CONTRAST] = [wx.NewId() for number in range(5)] |
@@ -98,7 +94,8 @@ class Frame(wx.Frame): | @@ -98,7 +94,8 @@ class Frame(wx.Frame): | ||
98 | 94 | ||
99 | def __bind_events_wx(self): | 95 | def __bind_events_wx(self): |
100 | self.Bind(wx.EVT_SIZE, self.OnSize) | 96 | self.Bind(wx.EVT_SIZE, self.OnSize) |
101 | - | 97 | + self.Bind(wx.EVT_MENU, self.OnMenuClick) |
98 | + | ||
102 | def __init_aui(self): | 99 | def __init_aui(self): |
103 | 100 | ||
104 | # Tell aui_manager to manage this frame | 101 | # Tell aui_manager to manage this frame |
@@ -202,6 +199,10 @@ class Frame(wx.Frame): | @@ -202,6 +199,10 @@ class Frame(wx.Frame): | ||
202 | def OnSize(self, evt): | 199 | def OnSize(self, evt): |
203 | ps.Publisher().sendMessage(('ProgressBar Reposition')) | 200 | ps.Publisher().sendMessage(('ProgressBar Reposition')) |
204 | evt.Skip() | 201 | evt.Skip() |
202 | + | ||
203 | + def OnMenuClick(self, evt): | ||
204 | + ps.Publisher().sendMessage(("Run menu item", | ||
205 | + str(evt.GetId()))) | ||
205 | 206 | ||
206 | def ShowTask(self, pubsub_evt): | 207 | def ShowTask(self, pubsub_evt): |
207 | self.aui_manager.GetPane("Tasks").Show() | 208 | self.aui_manager.GetPane("Tasks").Show() |
@@ -232,7 +233,7 @@ class MenuBar(wx.MenuBar): | @@ -232,7 +233,7 @@ class MenuBar(wx.MenuBar): | ||
232 | def __init_items(self): | 233 | def __init_items(self): |
233 | 234 | ||
234 | file_menu = wx.Menu() | 235 | file_menu = wx.Menu() |
235 | - file_menu.Append(ID_FILE_IMPORT, "Import...") | 236 | + file_menu.Append(const.ID_FILE_IMPORT, "Import...") |
236 | file_menu.Append(101, "Exit") | 237 | file_menu.Append(101, "Exit") |
237 | 238 | ||
238 | view_menu = wx.Menu() | 239 | view_menu = wx.Menu() |
@@ -416,19 +417,19 @@ class ProjectToolBar(wx.ToolBar): | @@ -416,19 +417,19 @@ class ProjectToolBar(wx.ToolBar): | ||
416 | BMP_PHOTO = wx.Bitmap(os.path.join(const.ICON_DIR, "tool_photo.png"), | 417 | BMP_PHOTO = wx.Bitmap(os.path.join(const.ICON_DIR, "tool_photo.png"), |
417 | wx.BITMAP_TYPE_PNG) | 418 | wx.BITMAP_TYPE_PNG) |
418 | 419 | ||
419 | - self.AddLabelTool(ID_FILE_IMPORT, | 420 | + self.AddLabelTool(const.ID_FILE_IMPORT, |
420 | "Import medical image...", | 421 | "Import medical image...", |
421 | BMP_IMPORT) | 422 | BMP_IMPORT) |
422 | - self.AddLabelTool(ID_FILE_LOAD_INTERNET, | 423 | + self.AddLabelTool(const.ID_FILE_LOAD_INTERNET, |
423 | "Load medical image...", | 424 | "Load medical image...", |
424 | BMP_NET) | 425 | BMP_NET) |
425 | - self.AddLabelTool(ID_FILE_SAVE, | 426 | + self.AddLabelTool(const.ID_FILE_SAVE, |
426 | "Save InVesalius project", | 427 | "Save InVesalius project", |
427 | BMP_SAVE) | 428 | BMP_SAVE) |
428 | - self.AddLabelTool(ID_FILE_PHOTO, | 429 | + self.AddLabelTool(const.ID_FILE_PHOTO, |
429 | "Take photo of screen", | 430 | "Take photo of screen", |
430 | BMP_PHOTO) | 431 | BMP_PHOTO) |
431 | - self.AddLabelTool(ID_FILE_PRINT, | 432 | + self.AddLabelTool(const.ID_FILE_PRINT, |
432 | "Print medical image...", | 433 | "Print medical image...", |
433 | BMP_PRINT) | 434 | BMP_PRINT) |
434 | 435 |
invesalius/gui/import_panel.py
@@ -72,7 +72,7 @@ class InnerPanel(wx.Panel): | @@ -72,7 +72,7 @@ class InnerPanel(wx.Panel): | ||
72 | ps.Publisher().subscribe(self.ShowDicomPreview, "Load import panel") | 72 | ps.Publisher().subscribe(self.ShowDicomPreview, "Load import panel") |
73 | 73 | ||
74 | def ShowDicomPreview(self, pubsub_evt): | 74 | def ShowDicomPreview(self, pubsub_evt): |
75 | - dicom_groups = pubsub_evt.data | 75 | + dicom_groups = pubsub_evt.data |
76 | self.text_panel.Populate(dicom_groups) | 76 | self.text_panel.Populate(dicom_groups) |
77 | 77 | ||
78 | 78 |
invesalius/gui/task_importer.py
@@ -21,6 +21,7 @@ import wx | @@ -21,6 +21,7 @@ import wx | ||
21 | import wx.lib.hyperlink as hl | 21 | import wx.lib.hyperlink as hl |
22 | import wx.lib.platebtn as pbtn | 22 | import wx.lib.platebtn as pbtn |
23 | import wx.lib.pubsub as ps | 23 | import wx.lib.pubsub as ps |
24 | +import constants as const | ||
24 | 25 | ||
25 | BTN_IMPORT_LOCAL = wx.NewId() | 26 | BTN_IMPORT_LOCAL = wx.NewId() |
26 | BTN_IMPORT_PACS = wx.NewId() | 27 | BTN_IMPORT_PACS = wx.NewId() |
@@ -134,7 +135,8 @@ class InnerTaskPanel(wx.Panel): | @@ -134,7 +135,8 @@ class InnerTaskPanel(wx.Panel): | ||
134 | # Test load and unload specific projects' links | 135 | # Test load and unload specific projects' links |
135 | self.TestLoadProjects() | 136 | self.TestLoadProjects() |
136 | #self.UnloadProjects() | 137 | #self.UnloadProjects() |
137 | - | 138 | + ps.Publisher().subscribe(self.OnLinkImport,("Run menu item", |
139 | + str(const.ID_FILE_IMPORT))) | ||
138 | 140 | ||
139 | def OnLinkImport(self, evt=None): | 141 | def OnLinkImport(self, evt=None): |
140 | dlg = wx.DirDialog(self, "Choose a directory:", "", | 142 | dlg = wx.DirDialog(self, "Choose a directory:", "", |
@@ -148,10 +150,13 @@ class InnerTaskPanel(wx.Panel): | @@ -148,10 +150,13 @@ class InnerTaskPanel(wx.Panel): | ||
148 | 150 | ||
149 | # Only destroy a dialog after you're done with it. | 151 | # Only destroy a dialog after you're done with it. |
150 | dlg.Destroy() | 152 | dlg.Destroy() |
151 | - | ||
152 | - if evt: | ||
153 | - evt.Skip() | ||
154 | - | 153 | + |
154 | + try: | ||
155 | + if evt: | ||
156 | + evt.Skip() | ||
157 | + except(AttributeError): | ||
158 | + pass | ||
159 | + | ||
155 | def OnLinkImportPACS(self, evt=None): | 160 | def OnLinkImportPACS(self, evt=None): |
156 | print "TODO: Send Signal - Import DICOM files from PACS" | 161 | print "TODO: Send Signal - Import DICOM files from PACS" |
157 | if evt: | 162 | if evt: |