Commit 2c4df64bf10ef155f2044a4dc33e8c6b80c8e7d7
1 parent
462913dd
Exists in
master
and in
68 other branches
FIX: Add "try.. exception..." temporary to fix error in the execute wx.SafeYield…
…() in the Windowds XP 64 Bits. Is bug wxWidgets.
Showing
2 changed files
with
56 additions
and
46 deletions
Show diff stats
invesalius/gui/dicom_preview_panel.py
... | ... | @@ -70,14 +70,14 @@ class SingleImagePreview(wx.Panel): |
70 | 70 | text_image_location.SetPosition(const.TEXT_POS_LEFT_DOWN) |
71 | 71 | text_image_location.SetValue("localization") |
72 | 72 | self.text_image_location = text_image_location |
73 | - | |
73 | + | |
74 | 74 | value = "id\nprotocol" |
75 | 75 | text_patient = vtku.Text() |
76 | 76 | text_patient.SetJustificationToRight() |
77 | 77 | text_patient.SetPosition(const.TEXT_POS_RIGHT_UP) |
78 | 78 | text_patient.SetValue(value) |
79 | 79 | self.text_patient = text_patient |
80 | - | |
80 | + | |
81 | 81 | value = "date time\n Made in InVesalius" |
82 | 82 | text_acquisition = vtku.Text() |
83 | 83 | text_acquisition.SetJustificationToRight() |
... | ... | @@ -130,7 +130,7 @@ class SingleImagePreview(wx.Panel): |
130 | 130 | in_sizer = wx.BoxSizer(wx.HORIZONTAL) |
131 | 131 | in_sizer.Add(slider, 1, wx.GROW|wx.EXPAND) |
132 | 132 | in_sizer.Add(checkbox, 0) |
133 | - | |
133 | + | |
134 | 134 | sizer = wx.BoxSizer(wx.VERTICAL) |
135 | 135 | sizer.Add(self.panel, 20, wx.GROW|wx.EXPAND) |
136 | 136 | sizer.Add(in_sizer, 1, wx.GROW|wx.EXPAND) |
... | ... | @@ -165,9 +165,15 @@ class SingleImagePreview(wx.Panel): |
165 | 165 | self.ShowSlice(pos) |
166 | 166 | time.sleep(0.2) |
167 | 167 | if self.ischecked: |
168 | - wx.Yield() | |
169 | - wx.CallAfter(self.OnRun) | |
170 | - | |
168 | + try: | |
169 | + wx.Yield() | |
170 | + #TODO: temporary fix necessary in the Windows XP 64 Bits | |
171 | + #BUG in wxWidgets http://trac.wxwidgets.org/ticket/10896 | |
172 | + except(wx._core.PyAssertionError): | |
173 | + print "wx._core.PyAssertionError" | |
174 | + finally: | |
175 | + wx.CallAfter(self.OnRun) | |
176 | + | |
171 | 177 | def SetDicomGroup(self, group): |
172 | 178 | self.dicom_list = group.GetHandSortedList() |
173 | 179 | self.current_index = 0 |
... | ... | @@ -181,7 +187,7 @@ class SingleImagePreview(wx.Panel): |
181 | 187 | def ShowSlice(self, index = 0): |
182 | 188 | print "ShowSlice" |
183 | 189 | dicom = self.dicom_list[index] |
184 | - | |
190 | + | |
185 | 191 | # UPDATE GUI |
186 | 192 | ## Text related to size |
187 | 193 | value = STR_SIZE %(dicom.image.size[0], dicom.image.size[1]) |
... | ... | @@ -274,10 +280,10 @@ class Preview(wx.Panel): |
274 | 280 | |
275 | 281 | def _init_ui(self): |
276 | 282 | |
277 | - self.title = wx.StaticText(self, -1, "Image", | |
283 | + self.title = wx.StaticText(self, -1, "Image", | |
278 | 284 | style=wx.ALIGN_CENTER) |
279 | 285 | |
280 | - self.subtitle = wx.StaticText(self, -1, "Image", | |
286 | + self.subtitle = wx.StaticText(self, -1, "Image", | |
281 | 287 | style=wx.ALIGN_CENTER) |
282 | 288 | |
283 | 289 | self.panel = wx.Panel(self, -1) |
... | ... | @@ -306,7 +312,7 @@ class Preview(wx.Panel): |
306 | 312 | def _init_vtk(self): |
307 | 313 | |
308 | 314 | self.interactor = wxVTKRenderWindowInteractor(self.panel, -1, size=(70, 70)) |
309 | - | |
315 | + | |
310 | 316 | sizer = wx.BoxSizer(wx.HORIZONTAL) |
311 | 317 | sizer.Add(self.interactor, 1, wx.GROW|wx.EXPAND) |
312 | 318 | sizer.Fit(self.panel) |
... | ... | @@ -316,7 +322,7 @@ class Preview(wx.Panel): |
316 | 322 | self.panel.Layout() |
317 | 323 | self.panel.Update() |
318 | 324 | self.panel.SetAutoLayout(1) |
319 | - | |
325 | + | |
320 | 326 | self.actor = vtk.vtkImageActor() |
321 | 327 | |
322 | 328 | self.render = vtk.vtkRenderer() |
... | ... | @@ -351,7 +357,7 @@ class Preview(wx.Panel): |
351 | 357 | self.title.Bind(wx.EVT_LEFT_DOWN, self.OnSelect) |
352 | 358 | self.subtitle.Bind(wx.EVT_LEFT_DOWN, self.OnSelect) |
353 | 359 | |
354 | - | |
360 | + | |
355 | 361 | |
356 | 362 | |
357 | 363 | def OnEnter(self, evt): |
... | ... | @@ -422,7 +428,7 @@ class Preview(wx.Panel): |
422 | 428 | image = image_file[0] |
423 | 429 | |
424 | 430 | scale = image.GetScalarRange() |
425 | - | |
431 | + | |
426 | 432 | cast = vtk.vtkImageMapToWindowLevelColors() |
427 | 433 | #cast.SetShift(abs(scale[0])) |
428 | 434 | #cast.SetScale(255.0/(scale[1] - scale[0])) |
... | ... | @@ -438,7 +444,7 @@ class Preview(wx.Panel): |
438 | 444 | window = 150 |
439 | 445 | |
440 | 446 | self.data = image_file[-1] |
441 | - | |
447 | + | |
442 | 448 | cast.SetWindow(window) |
443 | 449 | cast.SetLevel(level) |
444 | 450 | self.actor.SetInput(cast.GetOutput()) |
... | ... | @@ -485,7 +491,7 @@ class Preview(wx.Panel): |
485 | 491 | |
486 | 492 | |
487 | 493 | if 1: |
488 | - # Default values for the surronounding rectangle | |
494 | + # Default values for the surronounding rectangle | |
489 | 495 | # around a button |
490 | 496 | rectWidth = self._nImgSize * 2 # To avoid the recangle to 'touch' the borders |
491 | 497 | rectHeight = self._nImgSize * 2 |
... | ... | @@ -497,7 +503,7 @@ class Preview(wx.Panel): |
497 | 503 | # not ((style & INB_LEFT) or (style & INB_RIGHT)) and \ |
498 | 504 | # not self._pagesInfoVec[i].GetCaption() == "" and \ |
499 | 505 | # not (style & INB_SHOW_ONLY_IMAGES): |
500 | - | |
506 | + | |
501 | 507 | |
502 | 508 | #rectWidth = ((textWidth + nPadding * 2) > rectWidth and [nPadding * 2 + textWidth] or [rectWidth])[0] |
503 | 509 | |
... | ... | @@ -509,7 +515,7 @@ class Preview(wx.Panel): |
509 | 515 | # If Pin button is used, consider its space as well (applicable for top/botton style) |
510 | 516 | # since in the left/right, its size is already considered in 'pos' |
511 | 517 | #pinBtnSize = (bUsePin and [20] or [0])[0] |
512 | - | |
518 | + | |
513 | 519 | #if pos + rectWidth + pinBtnSize > clientSize: |
514 | 520 | # break |
515 | 521 | |
... | ... | @@ -562,7 +568,7 @@ class DicomPreviewSeries(wx.Panel): |
562 | 568 | self.SetAutoLayout(1) |
563 | 569 | |
564 | 570 | self.sizer = background_sizer |
565 | - | |
571 | + | |
566 | 572 | self._Add_Panels_Preview() |
567 | 573 | self._bind_events() |
568 | 574 | |
... | ... | @@ -579,7 +585,7 @@ class DicomPreviewSeries(wx.Panel): |
579 | 585 | |
580 | 586 | #def _show_shadow(self, preview): |
581 | 587 | # preview.ShowShadow() |
582 | - | |
588 | + | |
583 | 589 | |
584 | 590 | def _bind_events(self): |
585 | 591 | # When the user scrolls the window |
... | ... | @@ -609,7 +615,7 @@ class DicomPreviewSeries(wx.Panel): |
609 | 615 | group_list) |
610 | 616 | self.files.append(info) |
611 | 617 | n+=1 |
612 | - | |
618 | + | |
613 | 619 | scroll_range = len(self.files)/NCOLS |
614 | 620 | if scroll_range * NCOLS < len(self.files): |
615 | 621 | scroll_range +=1 |
... | ... | @@ -619,7 +625,7 @@ class DicomPreviewSeries(wx.Panel): |
619 | 625 | def _display_previews(self): |
620 | 626 | initial = self.displayed_position * NCOLS |
621 | 627 | final = initial + MAX_VALUE |
622 | - | |
628 | + | |
623 | 629 | if len(self.files) < final: |
624 | 630 | for i in xrange(final-len(self.files)): |
625 | 631 | try: |
... | ... | @@ -686,7 +692,7 @@ class DicomPreview(wx.Panel): |
686 | 692 | self.SetAutoLayout(1) |
687 | 693 | |
688 | 694 | self.sizer = background_sizer |
689 | - | |
695 | + | |
690 | 696 | self._Add_Panels_Preview() |
691 | 697 | self._bind_events() |
692 | 698 | |
... | ... | @@ -767,7 +773,7 @@ class DicomPreview(wx.Panel): |
767 | 773 | initial = self.displayed_position * NCOLS |
768 | 774 | final = initial + MAX_VALUE |
769 | 775 | print "len:", len(self.files) |
770 | - | |
776 | + | |
771 | 777 | if len(self.files) < final: |
772 | 778 | for i in xrange(final-len(self.files)): |
773 | 779 | print "hide ", i | ... | ... |
invesalius/gui/frame.py
... | ... | @@ -34,7 +34,7 @@ import project as prj |
34 | 34 | import session as ses |
35 | 35 | |
36 | 36 | # Object toolbar |
37 | -#OBJ_TOOLS = [ID_ZOOM, ID_ZOOM_SELECT, ID_ROTATE, ID_MOVE, | |
37 | +#OBJ_TOOLS = [ID_ZOOM, ID_ZOOM_SELECT, ID_ROTATE, ID_MOVE, | |
38 | 38 | #ID_CONTRAST] = [wx.NewId() for number in range(5)] |
39 | 39 | #MODE_BY_ID = {ID_ZOOM: const.STATE_ZOOM, |
40 | 40 | # ID_ZOOM_SELECT: const.STATE_ZOOM_SL, |
... | ... | @@ -111,7 +111,7 @@ class Frame(wx.Frame): |
111 | 111 | self.Bind(wx.EVT_SIZE, self.OnSize) |
112 | 112 | self.Bind(wx.EVT_MENU, self.OnMenuClick) |
113 | 113 | #self.Bind(wx.EVT_CLOSE, self.OnExit) |
114 | - | |
114 | + | |
115 | 115 | def __init_aui(self): |
116 | 116 | |
117 | 117 | # Tell aui_manager to manage this frame |
... | ... | @@ -127,7 +127,7 @@ class Frame(wx.Frame): |
127 | 127 | #CloseButton(False).Floatable(False). |
128 | 128 | #Layer(1).Left().MaximizeButton(False).Name("Task"). |
129 | 129 | #Position(0)) |
130 | - | |
130 | + | |
131 | 131 | |
132 | 132 | aui_manager.AddPane(viewers.Panel(self), wx.aui.AuiPaneInfo(). |
133 | 133 | Caption("Data panel").CaptionVisible(False). |
... | ... | @@ -214,12 +214,12 @@ class Frame(wx.Frame): |
214 | 214 | aui_manager = self.aui_manager |
215 | 215 | aui_manager.GetPane("Data").Show(0) |
216 | 216 | aui_manager.GetPane("Tasks").Show(1) |
217 | - aui_manager.Update() | |
217 | + aui_manager.Update() | |
218 | 218 | |
219 | 219 | def OnSize(self, evt): |
220 | 220 | ps.Publisher().sendMessage(('ProgressBar Reposition')) |
221 | 221 | evt.Skip() |
222 | - | |
222 | + | |
223 | 223 | def OnMenuClick(self, evt): |
224 | 224 | id = evt.GetId() |
225 | 225 | session = ses.Session() |
... | ... | @@ -234,7 +234,7 @@ class Frame(wx.Frame): |
234 | 234 | else: |
235 | 235 | self.SaveProject() |
236 | 236 | elif id == const.ID_PROJECT_SAVE_AS: |
237 | - self.SaveAsProject() | |
237 | + self.SaveAsProject() | |
238 | 238 | elif id == const.ID_PROJECT_CLOSE: |
239 | 239 | self.CloseProject() |
240 | 240 | #elif id == const.ID_EXIT: |
... | ... | @@ -269,15 +269,15 @@ class Frame(wx.Frame): |
269 | 269 | def Exit(self): |
270 | 270 | print "Exit" |
271 | 271 | ps.Publisher().sendMessage('Close Project') |
272 | - | |
272 | + | |
273 | 273 | def ShowTask(self, pubsub_evt): |
274 | 274 | self.aui_manager.GetPane("Tasks").Show() |
275 | 275 | self.aui_manager.Update() |
276 | - | |
276 | + | |
277 | 277 | def HideTask(self, pubsub_evt): |
278 | 278 | self.aui_manager.GetPane("Tasks").Hide() |
279 | 279 | self.aui_manager.Update() |
280 | - | |
280 | + | |
281 | 281 | |
282 | 282 | #def OnClose(self): |
283 | 283 | # # TODO: implement this, based on wx.Demo |
... | ... | @@ -436,8 +436,12 @@ class StatusBar(wx.StatusBar): |
436 | 436 | if (int(value) >= 99): |
437 | 437 | self.SetStatusText("",0) |
438 | 438 | if sys.platform == 'win32': |
439 | - wx.SafeYield() | |
440 | - | |
439 | + try: | |
440 | + wx.SafeYield() | |
441 | + #TODO: temporary fix necessary in the Windows XP 64 Bits | |
442 | + #BUG in wxWidgets http://trac.wxwidgets.org/ticket/10896 | |
443 | + except(wx._core.PyAssertionError): | |
444 | + print "wx._core.PyAssertionError" | |
441 | 445 | |
442 | 446 | def UpdateStatusLabel(self, pubsub_evt): |
443 | 447 | label = pubsub_evt.data |
... | ... | @@ -476,7 +480,7 @@ class ProjectToolBar(wx.ToolBar): |
476 | 480 | |
477 | 481 | self.__init_items() |
478 | 482 | self.__bind_events() |
479 | - | |
483 | + | |
480 | 484 | #FIXME: |
481 | 485 | self.save_as = True |
482 | 486 | |
... | ... | @@ -559,16 +563,16 @@ class ProjectToolBar(wx.ToolBar): |
559 | 563 | filename = (prj.name).replace(' ','_') |
560 | 564 | if prj.save_as: |
561 | 565 | filename = dlg.ShowSaveAsProjectDialog(filename) |
562 | - if filename: | |
566 | + if filename: | |
563 | 567 | prj.save_as = False |
564 | 568 | else: |
565 | 569 | return |
566 | 570 | ps.Publisher().sendMessage('Save Project',filename) |
567 | 571 | event.Skip() |
568 | - | |
569 | - | |
570 | 572 | |
571 | - | |
573 | + | |
574 | + | |
575 | + | |
572 | 576 | # ------------------------------------------------------------------ |
573 | 577 | |
574 | 578 | class ObjectToolBar(wx.ToolBar): |
... | ... | @@ -577,7 +581,7 @@ class ObjectToolBar(wx.ToolBar): |
577 | 581 | wx.DefaultSize, |
578 | 582 | wx.TB_FLAT|wx.TB_NODIVIDER | wx.TB_DOCKABLE) |
579 | 583 | |
580 | - self.SetToolBitmapSize(wx.Size(32,32)) | |
584 | + self.SetToolBitmapSize(wx.Size(32,32)) | |
581 | 585 | self.parent = parent |
582 | 586 | |
583 | 587 | self.__init_items() |
... | ... | @@ -603,7 +607,7 @@ class ObjectToolBar(wx.ToolBar): |
603 | 607 | "tool_contrast_original.png"), |
604 | 608 | wx.BITMAP_TYPE_PNG) |
605 | 609 | else: |
606 | - | |
610 | + | |
607 | 611 | BMP_ROTATE = wx.Bitmap(os.path.join(const.ICON_DIR, |
608 | 612 | "tool_rotate.gif"), |
609 | 613 | wx.BITMAP_TYPE_GIF) |
... | ... | @@ -665,7 +669,7 @@ class ObjectToolBar(wx.ToolBar): |
665 | 669 | self.ToggleTool(item, False) |
666 | 670 | |
667 | 671 | evt.Skip() |
668 | - | |
672 | + | |
669 | 673 | |
670 | 674 | def UntoggleAllItems(self, pubsub_evt=None): |
671 | 675 | for id in const.TOOL_STATES: |
... | ... | @@ -783,25 +787,25 @@ class LayoutToolBar(wx.ToolBar): |
783 | 787 | |
784 | 788 | self.AddLabelTool(ID_LAYOUT, "",bitmap=self.BMP_WITHOUT_MENU, shortHelp= "Hide task panel") |
785 | 789 | self.AddCheckTool(ID_TEXT, bitmap=BMP_TEXT, shortHelp= "Hide texts") |
786 | - | |
790 | + | |
787 | 791 | self.Realize() |
788 | 792 | |
789 | 793 | def __bind_events_wx(self): |
790 | 794 | self.Bind(wx.EVT_TOOL, self.OnClick) |
791 | - | |
795 | + | |
792 | 796 | def OnClick(self, event): |
793 | 797 | id = event.GetId() |
794 | 798 | if id == ID_LAYOUT: |
795 | 799 | self.OnTask() |
796 | 800 | elif id== ID_TEXT: |
797 | 801 | self.OnText(event) |
798 | - | |
802 | + | |
799 | 803 | |
800 | 804 | for item in VIEW_TOOLS: |
801 | 805 | state = self.GetToolState(item) |
802 | 806 | if state and (item != id): |
803 | 807 | self.ToggleTool(item, False) |
804 | - | |
808 | + | |
805 | 809 | def OnTask(self): |
806 | 810 | |
807 | 811 | if self.ontool: | ... | ... |