Commit 48a92d1eccdc664faee8f53bffc26c2ec7f57d24
1 parent
efc4e7bf
Exists in
master
and in
68 other branches
ADD: Reader Analyze File from Interface
Showing
2 changed files
with
45 additions
and
1 deletions
Show diff stats
invesalius/gui/dialogs.py
... | ... | @@ -134,6 +134,9 @@ class ProgressDialog(object): |
134 | 134 | WILDCARD_OPEN = "InVesalius 3 project (*.inv3)|*.inv3|"\ |
135 | 135 | "All files (*.*)|*.*" |
136 | 136 | |
137 | +WILDCARD_ANALYZE = "Analyze (*.hdr)|*.hdr|"\ | |
138 | + "All files (*.*)|*.*" | |
139 | + | |
137 | 140 | def ShowOpenProjectDialog(): |
138 | 141 | # Default system path |
139 | 142 | current_dir = os.path.abspath(".") |
... | ... | @@ -161,6 +164,35 @@ def ShowOpenProjectDialog(): |
161 | 164 | os.chdir(current_dir) |
162 | 165 | return filepath |
163 | 166 | |
167 | + | |
168 | +def ShowOpenAnalyzeDialog(): | |
169 | + # Default system path | |
170 | + current_dir = os.path.abspath(".") | |
171 | + dlg = wx.FileDialog(None, message=_("Open Analyze File..."), | |
172 | + defaultDir="", | |
173 | + defaultFile="", wildcard=WILDCARD_ANALYZE, | |
174 | + style=wx.OPEN|wx.CHANGE_DIR) | |
175 | + | |
176 | + # inv3 filter is default | |
177 | + dlg.SetFilterIndex(0) | |
178 | + | |
179 | + # Show the dialog and retrieve the user response. If it is the OK response, | |
180 | + # process the data. | |
181 | + filepath = None | |
182 | + try: | |
183 | + if dlg.ShowModal() == wx.ID_OK: | |
184 | + # This returns a Python list of files that were selected. | |
185 | + filepath = dlg.GetPath() | |
186 | + except(wx._core.PyAssertionError): #FIX: win64 | |
187 | + filepath = dlg.GetPath() | |
188 | + | |
189 | + # Destroy the dialog. Don't do this until you are done with it! | |
190 | + # BAD things can happen otherwise! | |
191 | + dlg.Destroy() | |
192 | + os.chdir(current_dir) | |
193 | + return filepath | |
194 | + | |
195 | + | |
164 | 196 | def ShowImportDirDialog(): |
165 | 197 | current_dir = os.path.abspath(".") |
166 | 198 | ... | ... |
invesalius/gui/frame.py
... | ... | @@ -294,6 +294,8 @@ class Frame(wx.Frame): |
294 | 294 | self.ShowImportDicomPanel() |
295 | 295 | elif id == const.ID_PROJECT_OPEN: |
296 | 296 | self.ShowOpenProject() |
297 | + elif id == const.ID_ANALYZE_IMPORT: | |
298 | + self.ShowAnalyzeImporter() | |
297 | 299 | elif id == const.ID_PROJECT_SAVE: |
298 | 300 | session = ses.Session() |
299 | 301 | if session.temp_item: |
... | ... | @@ -355,6 +357,12 @@ class Frame(wx.Frame): |
355 | 357 | Show save as dialog. |
356 | 358 | """ |
357 | 359 | ps.Publisher().sendMessage('Show save dialog', True) |
360 | + | |
361 | + def ShowAnalyzeImporter(self): | |
362 | + """ | |
363 | + Show save as dialog. | |
364 | + """ | |
365 | + ps.Publisher().sendMessage('Show analyze dialog', True) | |
358 | 366 | |
359 | 367 | # ------------------------------------------------------------------ |
360 | 368 | # ------------------------------------------------------------------ |
... | ... | @@ -396,12 +404,16 @@ class MenuBar(wx.MenuBar): |
396 | 404 | Create all menu and submenus, and add them to self. |
397 | 405 | """ |
398 | 406 | # TODO: This definetely needs improvements... ;) |
407 | + | |
408 | + #Import Others Files | |
409 | + others_file_menu = wx.Menu() | |
410 | + others_file_menu.Append(const.ID_ANALYZE_IMPORT, "Analyze") | |
399 | 411 | |
400 | 412 | # FILE |
401 | 413 | file_menu = wx.Menu() |
402 | 414 | app = file_menu.Append |
403 | 415 | app(const.ID_DICOM_IMPORT, _("Import DICOM...\tCtrl+I")) |
404 | - #app(const.ID_DICOM_LOAD_NET, _("Import DICOM from PACS...")) | |
416 | + file_menu.AppendMenu(const.ID_IMPORT_OTHERS_FILES, _("Import Others Files"), others_file_menu) | |
405 | 417 | app(const.ID_PROJECT_OPEN, _("Open Project...\tCtrl+O")) |
406 | 418 | app(const.ID_PROJECT_SAVE, _("Save Project\tCtrl+S")) |
407 | 419 | app(const.ID_PROJECT_SAVE_AS, _("Save Project As...")) | ... | ... |