Commit ef52a4957efdae9fe63f840cb0d5179456c937e7
1 parent
4ed0515b
Exists in
master
and in
6 other branches
FIX: Error save preset name in win64
Showing
1 changed file
with
26 additions
and
22 deletions
Show diff stats
invesalius/gui/dialogs.py
... | ... | @@ -31,7 +31,7 @@ import project |
31 | 31 | class NumberDialog(wx.Dialog): |
32 | 32 | def __init__(self, message, value=0): |
33 | 33 | pre = wx.PreDialog() |
34 | - pre.Create(None, -1, "InVesalius 3", size=wx.DefaultSize, pos=wx.DefaultPosition, | |
34 | + pre.Create(None, -1, "InVesalius 3", size=wx.DefaultSize, pos=wx.DefaultPosition, | |
35 | 35 | style=wx.DEFAULT_DIALOG_STYLE) |
36 | 36 | self.PostCreate(pre) |
37 | 37 | |
... | ... | @@ -46,7 +46,7 @@ class NumberDialog(wx.Dialog): |
46 | 46 | signedForegroundColour = "Black") |
47 | 47 | self.num_ctrl = num_ctrl |
48 | 48 | |
49 | - # Buttons | |
49 | + # Buttons | |
50 | 50 | btn_ok = wx.Button(self, wx.ID_OK) |
51 | 51 | btn_ok.SetHelpText(_("Value will be applied.")) |
52 | 52 | btn_ok.SetDefault() |
... | ... | @@ -57,7 +57,7 @@ class NumberDialog(wx.Dialog): |
57 | 57 | btnsizer = wx.StdDialogButtonSizer() |
58 | 58 | btnsizer.AddButton(btn_ok) |
59 | 59 | btnsizer.AddButton(btn_cancel) |
60 | - btnsizer.Realize() | |
60 | + btnsizer.Realize() | |
61 | 61 | |
62 | 62 | |
63 | 63 | sizer = wx.BoxSizer(wx.VERTICAL) |
... | ... | @@ -104,15 +104,15 @@ class ProgressDialog(object): |
104 | 104 | #| wx.PD_ESTIMATED_TIME |
105 | 105 | #| wx.PD_REMAINING_TIME |
106 | 106 | ) |
107 | - | |
107 | + | |
108 | 108 | self.dlg.Bind(wx.EVT_BUTTON, self.Cancel) |
109 | 109 | self.dlg.SetSize(wx.Size(250,150)) |
110 | - | |
110 | + | |
111 | 111 | def Cancel(self, evt): |
112 | 112 | ps.Publisher().sendMessage("Cancel DICOM load") |
113 | - | |
113 | + | |
114 | 114 | def Update(self, value, message): |
115 | - if(int(value) != self.maximum): | |
115 | + if(int(value) != self.maximum): | |
116 | 116 | try: |
117 | 117 | self.dlg.Update(value,message) |
118 | 118 | #TODO: |
... | ... | @@ -122,7 +122,7 @@ class ProgressDialog(object): |
122 | 122 | return True |
123 | 123 | else: |
124 | 124 | return False |
125 | - | |
125 | + | |
126 | 126 | def Close(self): |
127 | 127 | self.dlg.Destroy() |
128 | 128 | |
... | ... | @@ -184,7 +184,7 @@ def ShowImportDirDialog(): |
184 | 184 | return path |
185 | 185 | |
186 | 186 | def ShowSaveAsProjectDialog(default_filename=None): |
187 | - current_dir = os.path.abspath(".") | |
187 | + current_dir = os.path.abspath(".") | |
188 | 188 | dlg = wx.FileDialog(None, |
189 | 189 | _("Save project as..."), # title |
190 | 190 | "", # last used directory |
... | ... | @@ -193,14 +193,14 @@ def ShowSaveAsProjectDialog(default_filename=None): |
193 | 193 | wx.SAVE|wx.OVERWRITE_PROMPT) |
194 | 194 | #dlg.SetFilterIndex(0) # default is VTI |
195 | 195 | |
196 | - filename = None | |
196 | + filename = None | |
197 | 197 | if dlg.ShowModal() == wx.ID_OK: |
198 | 198 | filename = dlg.GetPath() |
199 | 199 | extension = "inv3" |
200 | 200 | if sys.platform != 'win32': |
201 | 201 | if filename.split(".")[-1] != extension: |
202 | 202 | filename = filename + "." + extension |
203 | - | |
203 | + | |
204 | 204 | os.chdir(current_dir) |
205 | 205 | return filename |
206 | 206 | |
... | ... | @@ -217,14 +217,14 @@ def ShowSaveAsProjectDialog(default_filename=None): |
217 | 217 | class MessageDialog(wx.Dialog): |
218 | 218 | def __init__(self, message): |
219 | 219 | pre = wx.PreDialog() |
220 | - pre.Create(None, -1, "InVesalius 3", size=(360, 370), pos=wx.DefaultPosition, | |
220 | + pre.Create(None, -1, "InVesalius 3", size=(360, 370), pos=wx.DefaultPosition, | |
221 | 221 | style=wx.DEFAULT_DIALOG_STYLE|wx.ICON_INFORMATION) |
222 | 222 | self.PostCreate(pre) |
223 | 223 | |
224 | 224 | # Static text which contains message to user |
225 | 225 | label = wx.StaticText(self, -1, message) |
226 | 226 | |
227 | - # Buttons | |
227 | + # Buttons | |
228 | 228 | btn_yes = wx.Button(self, wx.ID_YES) |
229 | 229 | btn_yes.SetHelpText("") |
230 | 230 | btn_yes.SetDefault() |
... | ... | @@ -239,7 +239,7 @@ class MessageDialog(wx.Dialog): |
239 | 239 | btnsizer.AddButton(btn_yes) |
240 | 240 | btnsizer.AddButton(btn_cancel) |
241 | 241 | btnsizer.AddButton(btn_no) |
242 | - btnsizer.Realize() | |
242 | + btnsizer.Realize() | |
243 | 243 | |
244 | 244 | |
245 | 245 | sizer = wx.BoxSizer(wx.VERTICAL) |
... | ... | @@ -263,7 +263,7 @@ def SaveChangesDialog__Old(filename): |
263 | 263 | return 0 |
264 | 264 | else: |
265 | 265 | return -1 |
266 | - | |
266 | + | |
267 | 267 | |
268 | 268 | def ImportEmptyDirectory(dirpath): |
269 | 269 | msg = "%s is an empty directory." % dirpath |
... | ... | @@ -274,7 +274,7 @@ def ImportEmptyDirectory(dirpath): |
274 | 274 | else: |
275 | 275 | dlg = wx.MessageDialog(None, msg, |
276 | 276 | "InVesalius 3", |
277 | - wx.ICON_INFORMATION | wx.OK) | |
277 | + wx.ICON_INFORMATION | wx.OK) | |
278 | 278 | dlg.ShowModal() |
279 | 279 | dlg.Destroy() |
280 | 280 | |
... | ... | @@ -285,9 +285,9 @@ def ImportInvalidFiles(): |
285 | 285 | wx.ICON_INFORMATION | wx.OK) |
286 | 286 | else: |
287 | 287 | dlg = wx.MessageDialog(None, msg, "InVesalius 3", |
288 | - wx.ICON_INFORMATION | wx.OK) | |
288 | + wx.ICON_INFORMATION | wx.OK) | |
289 | 289 | dlg.ShowModal() |
290 | - dlg.Destroy() | |
290 | + dlg.Destroy() | |
291 | 291 | |
292 | 292 | def SaveChangesDialog(filename): |
293 | 293 | current_dir = os.path.abspath(".") |
... | ... | @@ -303,7 +303,7 @@ def SaveChangesDialog(filename): |
303 | 303 | answer = dlg.ShowModal() |
304 | 304 | dlg.Destroy() |
305 | 305 | os.chdir(current_dir) |
306 | - | |
306 | + | |
307 | 307 | if answer == wx.ID_YES: |
308 | 308 | return 1 |
309 | 309 | elif answer == wx.ID_NO: |
... | ... | @@ -333,7 +333,7 @@ def SaveChangesDialog2(filename): |
333 | 333 | |
334 | 334 | |
335 | 335 | def ShowAboutDialog(parent): |
336 | - | |
336 | + | |
337 | 337 | info = wx.AboutDialogInfo() |
338 | 338 | info.Name = "InVesalius" |
339 | 339 | info.Version = "3.a.1 - RP" |
... | ... | @@ -364,7 +364,11 @@ def ShowSavePresetDialog(default_filename="raycasting"): |
364 | 364 | _("Save raycasting preset as:"), |
365 | 365 | "InVesalius 3") |
366 | 366 | #dlg.SetFilterIndex(0) # default is VTI |
367 | - filename = None | |
368 | - if dlg.ShowModal() == wx.ID_OK: | |
367 | + filename = None | |
368 | + try: | |
369 | + if dlg.ShowModal() == wx.ID_OK: | |
370 | + filename = dlg.GetValue() | |
371 | + except(wx._core.PyAssertionErro): | |
369 | 372 | filename = dlg.GetValue() |
373 | + | |
370 | 374 | return filename | ... | ... |