Commit fc5829b6f2e79e1aa95f3b74c45281f846606fda

Authored by Thiago Franco de Moraes
1 parent 5bc16544
Exists in master

Not using wx.ProgressDialog in brain segmenter gui

Showing 1 changed file with 18 additions and 20 deletions   Show diff stats
invesalius/gui/brain_seg_dialog.py
... ... @@ -48,7 +48,7 @@ class BrainSegmenterDialog(wx.Dialog):
48 48 if HAS_THEANO:
49 49 backends.append("Theano")
50 50 self.segmenter = segment.BrainSegmenter()
51   - self.pg_dialog = None
  51 + # self.pg_dialog = None
52 52  
53 53 self.cb_backends = wx.ComboBox(self, wx.ID_ANY, choices=backends, value=backends[0], style=wx.CB_DROPDOWN | wx.CB_READONLY)
54 54 w, h = self.CalcSizeFromTextSize("MM" * (1 + max(len(i) for i in backends)))
... ... @@ -60,10 +60,10 @@ class BrainSegmenterDialog(wx.Dialog):
60 60 self.txt_threshold = wx.TextCtrl(self, wx.ID_ANY, "")
61 61 w, h = self.CalcSizeFromTextSize("MMMMM")
62 62 self.txt_threshold.SetMinClientSize((w, -1))
63   - # self.progress = wx.Gauge(self, -1)
  63 + self.progress = wx.Gauge(self, -1)
64 64 self.btn_segment = wx.Button(self, wx.ID_ANY, _("Segment"))
65   - # self.btn_stop = wx.Button(self, wx.ID_ANY, _("Stop"))
66   - # self.btn_stop.Disable()
  65 + self.btn_stop = wx.Button(self, wx.ID_ANY, _("Stop"))
  66 + self.btn_stop.Disable()
67 67  
68 68 self.txt_threshold.SetValue("{:3d}%".format(self.sld_threshold.GetValue()))
69 69  
... ... @@ -84,9 +84,9 @@ class BrainSegmenterDialog(wx.Dialog):
84 84 sizer_3.Add(self.sld_threshold, 1, wx.ALIGN_CENTER | wx.BOTTOM | wx.EXPAND | wx.LEFT | wx.RIGHT, 5)
85 85 sizer_3.Add(self.txt_threshold, 0, wx.ALL, 5)
86 86 main_sizer.Add(sizer_3, 0, wx.EXPAND, 0)
87   - # main_sizer.Add(self.progress, 0, wx.EXPAND | wx.ALL, 5)
  87 + main_sizer.Add(self.progress, 0, wx.EXPAND | wx.ALL, 5)
88 88 sizer_buttons = wx.BoxSizer(wx.HORIZONTAL)
89   - # sizer_buttons.Add(self.btn_stop, 0, wx.ALIGN_BOTTOM | wx.ALIGN_RIGHT | wx.ALL, 5)
  89 + sizer_buttons.Add(self.btn_stop, 0, wx.ALIGN_BOTTOM | wx.ALIGN_RIGHT | wx.ALL, 5)
90 90 sizer_buttons.Add(self.btn_segment, 0, wx.ALIGN_BOTTOM | wx.ALIGN_RIGHT | wx.ALL, 5)
91 91 main_sizer.Add(sizer_buttons, 0, wx.ALIGN_BOTTOM | wx.ALIGN_RIGHT | wx.ALL, 0)
92 92 self.SetSizer(main_sizer)
... ... @@ -99,7 +99,7 @@ class BrainSegmenterDialog(wx.Dialog):
99 99 self.sld_threshold.Bind(wx.EVT_SCROLL, self.OnScrollThreshold)
100 100 self.txt_threshold.Bind(wx.EVT_KILL_FOCUS, self.OnKillFocus)
101 101 self.btn_segment.Bind(wx.EVT_BUTTON, self.OnSegment)
102   - # self.btn_stop.Bind(wx.EVT_BUTTON, self.OnStop)
  102 + self.btn_stop.Bind(wx.EVT_BUTTON, self.OnStop)
103 103 self.Bind(wx.EVT_CLOSE, self.OnClose)
104 104  
105 105 def CalcSizeFromTextSize(self, text):
... ... @@ -138,18 +138,18 @@ class BrainSegmenterDialog(wx.Dialog):
138 138 backend = self.cb_backends.GetValue()
139 139 use_gpu = self.chk_use_gpu.GetValue()
140 140 prob_threshold = self.sld_threshold.GetValue() / 100.0
141   - # self.btn_stop.Enable()
  141 + self.btn_stop.Enable()
142 142 self.btn_segment.Disable()
143   - self.pg_dialog = wx.ProgressDialog(_("Brain segmenter"), _("Segmenting brain"), parent=self, style= wx.FRAME_FLOAT_ON_PARENT | wx.PD_CAN_ABORT | wx.PD_AUTO_HIDE | wx.PD_ELAPSED_TIME)
144   - self.pg_dialog.Bind(wx.EVT_BUTTON, self.OnStop)
145   - self.pg_dialog.Show()
  143 + # self.pg_dialog = wx.ProgressDialog(_("Brain segmenter"), _("Segmenting brain"), parent=self, style= wx.FRAME_FLOAT_ON_PARENT | wx.PD_CAN_ABORT | wx.PD_AUTO_HIDE | wx.PD_ELAPSED_TIME)
  144 + # self.pg_dialog.Bind(wx.EVT_BUTTON, self.OnStop)
  145 + # self.pg_dialog.Show()
146 146 self.segmenter.segment(image, prob_threshold, backend, use_gpu, self.SetProgress, self.AfterSegment)
147 147  
148 148 def OnStop(self, evt):
149 149 self.segmenter.stop = True
150   - # self.btn_stop.Disable()
151   - self.pg_dialog.Hide()
152   - self.pg_dialog = None
  150 + self.btn_stop.Disable()
  151 + # self.pg_dialog.Hide()
  152 + # self.pg_dialog = None
153 153 self.btn_segment.Enable()
154 154 evt.Skip()
155 155  
... ... @@ -157,17 +157,15 @@ class BrainSegmenterDialog(wx.Dialog):
157 157 Publisher.sendMessage('Reload actual slice')
158 158  
159 159 def SetProgress(self, progress):
160   - # self.progress.SetValue(progress * 100)
161   - self.pg_dialog.Update(progress * 100)
  160 + self.progress.SetValue(progress * 100)
  161 + # self.pg_dialog.Update(progress * 100)
162 162 wx.GetApp().Yield()
163 163  
164 164 def OnClose(self, evt):
165 165 self.segmenter.stop = True
166   - # self.btn_stop.Disable()
  166 + self.btn_stop.Disable()
167 167 self.btn_segment.Enable()
168   - # self.progress.SetValue(0)
169   - if self.pg_dialog is not None:
170   - self.pg_dialog.Destroy()
  168 + self.progress.SetValue(0)
171 169 self.Destroy()
172 170  
173 171  
... ...