Commit 4b9937f4f5ab6b2b4d562c1e882bc4325c67e5be
1 parent
6d45778d
Exists in
ffill_gui
Ok and cancel button in select parts dialog
Showing
2 changed files
with
27 additions
and
6 deletions
Show diff stats
invesalius/data/styles.py
... | ... | @@ -1904,20 +1904,28 @@ class SelectMaskPartsInteractorStyle(DefaultInteractorStyle): |
1904 | 1904 | self.dlg.Show() |
1905 | 1905 | |
1906 | 1906 | def CleanUp(self): |
1907 | - if (self.dlg is not None) and (self.config.dlg_visible): | |
1907 | + if self.dlg is None: | |
1908 | + return | |
1909 | + | |
1910 | + dialog_return = self.dlg.button_clicked | |
1911 | + | |
1912 | + if self.config.dlg_visible: | |
1908 | 1913 | self.config.dlg_visible = False |
1909 | 1914 | self.dlg.Destroy() |
1910 | 1915 | self.dlg = None |
1911 | 1916 | |
1912 | 1917 | if self.config.mask: |
1913 | - self.config.mask.name = self.config.mask_name | |
1914 | - self.viewer.slice_._add_mask_into_proj(self.config.mask) | |
1915 | - self.viewer.slice_.SelectCurrentMask(self.config.mask.index) | |
1916 | - Publisher.sendMessage('Change mask selected', self.config.mask.index) | |
1917 | - self.config.mask = None | |
1918 | + if dialog_return == wx.OK: | |
1919 | + self.config.mask.name = self.config.mask_name | |
1920 | + self.viewer.slice_._add_mask_into_proj(self.config.mask) | |
1921 | + self.viewer.slice_.SelectCurrentMask(self.config.mask.index) | |
1922 | + Publisher.sendMessage('Change mask selected', self.config.mask.index) | |
1923 | + | |
1918 | 1924 | del self.viewer.slice_.aux_matrices['SELECT'] |
1919 | 1925 | self.viewer.slice_.to_show_aux = '' |
1920 | 1926 | Publisher.sendMessage('Reload actual slice') |
1927 | + self.config.mask = None | |
1928 | + | |
1921 | 1929 | |
1922 | 1930 | def OnSelect(self, obj, evt): |
1923 | 1931 | if (self.viewer.slice_.buffer_slices[self.orientation].mask is None): | ... | ... |
invesalius/gui/dialogs.py
... | ... | @@ -2024,6 +2024,8 @@ class SelectPartsOptionsDialog(wx.Dialog): |
2024 | 2024 | |
2025 | 2025 | self.config = config |
2026 | 2026 | |
2027 | + self.button_clicked = wx.CANCEL | |
2028 | + | |
2027 | 2029 | self._init_gui() |
2028 | 2030 | |
2029 | 2031 | def _init_gui(self): |
... | ... | @@ -2097,10 +2099,21 @@ class SelectPartsOptionsDialog(wx.Dialog): |
2097 | 2099 | sizer.Fit(self) |
2098 | 2100 | self.Layout() |
2099 | 2101 | |
2102 | + self.btn_ok.Bind(wx.EVT_BUTTON, self.OnOk) | |
2103 | + self.btn_cancel.Bind(wx.EVT_BUTTON, self.OnCancel) | |
2104 | + | |
2100 | 2105 | self.target_name.Bind(wx.EVT_CHAR, self.OnChar) |
2101 | 2106 | self.Bind(wx.EVT_RADIOBUTTON, self.OnSetRadio) |
2102 | 2107 | self.Bind(wx.EVT_CLOSE, self.OnClose) |
2103 | 2108 | |
2109 | + def OnOk(self, evt): | |
2110 | + self.button_clicked = wx.OK | |
2111 | + self.Close() | |
2112 | + | |
2113 | + def OnCancel(self, evt): | |
2114 | + self.button_clicked = wx.CANCEL | |
2115 | + self.Close() | |
2116 | + | |
2104 | 2117 | def OnChar(self, evt): |
2105 | 2118 | evt.Skip() |
2106 | 2119 | self.config.mask_name = self.target_name.GetValue() | ... | ... |