Commit 0c9ee0bd1230f607be04e59a1ebf55988a1677fa
1 parent
8baa3296
Exists in
master
and in
68 other branches
ENH: Cancel button working in import panel
Showing
1 changed file
with
21 additions
and
16 deletions
Show diff stats
invesalius/gui/import_panel.py
| @@ -92,11 +92,11 @@ class InnerPanel(wx.Panel): | @@ -92,11 +92,11 @@ class InnerPanel(wx.Panel): | ||
| 92 | 92 | ||
| 93 | self.btn_ok = wx.Button(panel, wx.ID_OK) | 93 | self.btn_ok = wx.Button(panel, wx.ID_OK) |
| 94 | self.btn_ok.SetDefault() | 94 | self.btn_ok.SetDefault() |
| 95 | - btn_cancel = wx.Button(panel, wx.ID_CANCEL) | 95 | + self.btn_cancel = wx.Button(panel, wx.ID_CANCEL) |
| 96 | 96 | ||
| 97 | btnsizer = wx.StdDialogButtonSizer() | 97 | btnsizer = wx.StdDialogButtonSizer() |
| 98 | btnsizer.AddButton(self.btn_ok) | 98 | btnsizer.AddButton(self.btn_ok) |
| 99 | - btnsizer.AddButton(btn_cancel) | 99 | + btnsizer.AddButton(self.btn_cancel) |
| 100 | btnsizer.Realize() | 100 | btnsizer.Realize() |
| 101 | 101 | ||
| 102 | self.combo_interval = wx.ComboBox(panel, -1, "", choices=const.IMPORT_INTERVAL, | 102 | self.combo_interval = wx.ComboBox(panel, -1, "", choices=const.IMPORT_INTERVAL, |
| @@ -133,8 +133,9 @@ class InnerPanel(wx.Panel): | @@ -133,8 +133,9 @@ class InnerPanel(wx.Panel): | ||
| 133 | self.Bind(EVT_SELECT_SERIE, self.OnSelectSerie) | 133 | self.Bind(EVT_SELECT_SERIE, self.OnSelectSerie) |
| 134 | self.Bind(EVT_SELECT_SLICE, self.OnSelectSlice) | 134 | self.Bind(EVT_SELECT_SLICE, self.OnSelectSlice) |
| 135 | self.Bind(EVT_SELECT_PATIENT, self.OnSelectPatient) | 135 | self.Bind(EVT_SELECT_PATIENT, self.OnSelectPatient) |
| 136 | - self.btn_ok.Bind(wx.EVT_BUTTON, self.OnLoadDicom) | ||
| 137 | - self.text_panel.Bind(EVT_SELECT_SERIE_TEXT, self.OnLoadDicom) | 136 | + self.btn_ok.Bind(wx.EVT_BUTTON, self.OnClickOk) |
| 137 | + self.btn_cancel.Bind(wx.EVT_BUTTON, self.OnClickCancel) | ||
| 138 | + self.text_panel.Bind(EVT_SELECT_SERIE_TEXT, self.OnDblClickTextPanel) | ||
| 138 | 139 | ||
| 139 | def ShowDicomPreview(self, pubsub_evt): | 140 | def ShowDicomPreview(self, pubsub_evt): |
| 140 | dicom_groups = pubsub_evt.data | 141 | dicom_groups = pubsub_evt.data |
| @@ -156,10 +157,21 @@ class InnerPanel(wx.Panel): | @@ -156,10 +157,21 @@ class InnerPanel(wx.Panel): | ||
| 156 | def OnSelectPatient(self, evt): | 157 | def OnSelectPatient(self, evt): |
| 157 | print "You've selected the patient", evt.GetSelectID() | 158 | print "You've selected the patient", evt.GetSelectID() |
| 158 | 159 | ||
| 159 | - def OnLoadDicom(self, evt): | 160 | + def OnDblClickTextPanel(self, evt): |
| 161 | + group = evt.GetItemData() | ||
| 162 | + self.LoadDicom(group) | ||
| 163 | + | ||
| 164 | + def OnClickOk(self, evt): | ||
| 160 | group = self.text_panel.GetSelection() | 165 | group = self.text_panel.GetSelection() |
| 161 | - interval = self.combo_interval.GetSelection() | 166 | + self.LoadDicom(group) |
| 167 | + | ||
| 168 | + def OnClickCancel(self, evt): | ||
| 169 | + ps.Publisher().sendMessage("Cancel DICOM load") | ||
| 162 | 170 | ||
| 171 | + def LoadDicom(self, group): | ||
| 172 | + interval = self.combo_interval.GetSelection() | ||
| 173 | + if not isinstance(group, dcm.DicomGroup): | ||
| 174 | + group = max(group.GetGroups(), key=lambda g: g.nslices) | ||
| 163 | ps.Publisher().sendMessage('Open DICOM group', (group, interval)) | 175 | ps.Publisher().sendMessage('Open DICOM group', (group, interval)) |
| 164 | 176 | ||
| 165 | 177 | ||
| @@ -284,7 +296,6 @@ class TextPanel(wx.Panel): | @@ -284,7 +296,6 @@ class TextPanel(wx.Panel): | ||
| 284 | def OnSelChanged(self, evt): | 296 | def OnSelChanged(self, evt): |
| 285 | item = self.tree.GetSelection() | 297 | item = self.tree.GetSelection() |
| 286 | if self._selected_by_user: | 298 | if self._selected_by_user: |
| 287 | - print "Yes, I'm here" | ||
| 288 | group = self.tree.GetItemPyData(item) | 299 | group = self.tree.GetItemPyData(item) |
| 289 | if isinstance(group, dcm.DicomGroup): | 300 | if isinstance(group, dcm.DicomGroup): |
| 290 | ps.Publisher().sendMessage('Load group into import panel', | 301 | ps.Publisher().sendMessage('Load group into import panel', |
| @@ -306,15 +317,9 @@ class TextPanel(wx.Panel): | @@ -306,15 +317,9 @@ class TextPanel(wx.Panel): | ||
| 306 | def OnActivate(self, evt): | 317 | def OnActivate(self, evt): |
| 307 | item = evt.GetItem() | 318 | item = evt.GetItem() |
| 308 | group = self.tree.GetItemPyData(item) | 319 | group = self.tree.GetItemPyData(item) |
| 309 | - if isinstance(group, dcm.DicomGroup): | ||
| 310 | - my_evt = SelectEvent(myEVT_SELECT_SERIE_TEXT, self.GetId()) | ||
| 311 | - my_evt.SetItemData(group) | ||
| 312 | - self.GetEventHandler().ProcessEvent(my_evt) | ||
| 313 | - else: | ||
| 314 | - if self.tree.IsExpanded(item): | ||
| 315 | - self.tree.Collapse(item) | ||
| 316 | - else: | ||
| 317 | - self.tree.Expand(item) | 320 | + my_evt = SelectEvent(myEVT_SELECT_SERIE_TEXT, self.GetId()) |
| 321 | + my_evt.SetItemData(group) | ||
| 322 | + self.GetEventHandler().ProcessEvent(my_evt) | ||
| 318 | 323 | ||
| 319 | def OnSize(self, evt): | 324 | def OnSize(self, evt): |
| 320 | self.tree.SetSize(self.GetSize()) | 325 | self.tree.SetSize(self.GetSize()) |