@@ -176,8 +176,9 @@ def OnResults(self, keyskeep, keysrem):
176176 for Page in pagerem :
177177 j = self .parent .notebook .GetPageIndex (Page )
178178 self .parent .notebook .DeletePage (j )
179+ self .OnPageChanged ()
179180 dlg .Destroy ()
180- self . OnPageChanged ()
181+
181182
182183
183184 def OnSelectionChanged (self , keylist , trigger = None ):
@@ -239,7 +240,7 @@ def __init__(self, parent, curvedict, wrapper=None, selkeys=None,
239240 # Get the window positioning correctly
240241 pos = self .parent .GetPosition ()
241242 pos = (pos [0 ]+ 100 , pos [1 ]+ 100 )
242- wx .Frame .__init__ (self , parent = self .parent , title = "Curve selection " ,
243+ wx .Frame .__init__ (self , parent = self .parent , title = "Overlay curves " ,
243244 pos = pos , style = wx .DEFAULT_FRAME_STYLE | wx .FRAME_FLOAT_ON_PARENT ,
244245 size = (800 ,500 ))
245246 ## Pre-process
@@ -254,8 +255,7 @@ def __init__(self, parent, curvedict, wrapper=None, selkeys=None,
254255 ctrl = "Apple"
255256 else :
256257 ctrl = "Ctrl"
257- text = "Select the curves to keep. \n " + \
258- "By holding down the '" + ctrl + "' key, single curves can be \n " + \
258+ text = "By holding down the '" + ctrl + "' key, single curves can be \n " + \
259259 "selected or deselected. The 'Shift' key can be used \n " + \
260260 "to select groups."
261261 self .upperSizer .Add (wx .StaticText (panel_top , label = text ))
@@ -278,15 +278,23 @@ def __init__(self, parent, curvedict, wrapper=None, selkeys=None,
278278 if self .selkeys .count (self .curvekeys [i ]) == 0 :
279279 self .SelectBox .Deselect (i )
280280 self .Bind (wx .EVT_LISTBOX , self .OnUpdatePlot , self .SelectBox )
281- self .boxSizer .Add (self .SelectBox )
282- # Button APPLY
283- btnok = wx .Button (panel_bottom , wx .ID_ANY , 'Apply' )
284- self .Bind (wx .EVT_BUTTON , self .OnPushResults , btnok )
285- self .boxSizer .Add (btnok )
281+ self .boxSizer .Add (self .SelectBox , wx .EXPAND )
282+ minsx = self .boxSizer .GetMinSize ()[0 ]
283+ # Button REMOVE
284+ btnrem = wx .Button (panel_bottom , wx .ID_ANY , 'Remove selected' )
285+ self .Bind (wx .EVT_BUTTON , self .OnPushResultsRemove , btnrem )
286+ btnrem .SetMinSize ((minsx , - 1 ))
287+ self .boxSizer .Add (btnrem )
288+ # Button KEEP
289+ btnkep = wx .Button (panel_bottom , wx .ID_ANY , 'Keep selected' )
290+ self .Bind (wx .EVT_BUTTON , self .OnPushResultsKeep , btnkep )
291+ self .boxSizer .Add (btnkep )
292+ btnkep .SetMinSize ((minsx , - 1 ))
286293 # Button CANCEL
287294 btncancel = wx .Button (panel_bottom , wx .ID_ANY , 'Cancel' )
288295 self .Bind (wx .EVT_BUTTON , self .OnCancel , btncancel )
289296 self .boxSizer .Add (btncancel )
297+ btncancel .SetMinSize ((minsx , - 1 ))
290298 # Finish off sizers
291299 panel_top .SetSizer (self .upperSizer )
292300 panel_bottom .SetSizer (self .boxSizer )
@@ -313,6 +321,17 @@ def __init__(self, parent, curvedict, wrapper=None, selkeys=None,
313321 self .Show (True )
314322
315323
324+ def GetSelection (self ):
325+ keyssel = list ()
326+ for i in self .SelectBox .GetSelections ():
327+ keyssel .append (self .curvekeys [i ])
328+ keysnosel = list ()
329+ for key in self .curvekeys :
330+ if keyssel .count (key ) == 0 :
331+ keysnosel .append (key )
332+ return keyssel , keysnosel
333+
334+
316335 def ProcessDict (self , e = None ):
317336 # Define the order of keys used.
318337 # We want to sort the keys, such that #10: is not before #1:
@@ -341,15 +360,15 @@ def OnCancel(self, e=None):
341360 self .wrapper .OnClose ()
342361
343362
344- def OnPushResults (self , e = None ):
363+ def OnPushResultsRemove (self , e = None ):
345364 # Get keys from selection
346- keyskeep = list ()
347- for i in self .SelectBox . GetSelections ():
348- keyskeep . append ( self . curvekeys [ i ])
349- keysrem = list ()
350- for key in self . curvekeys :
351- if keyskeep . count ( key ) == 0 :
352- keysrem . append ( key )
365+ keysrem , keyskeep = self . GetSelection ()
366+ self .wrapper . OnResults ( keyskeep , keysrem )
367+
368+
369+ def OnPushResultsKeep ( self , e = None ) :
370+ # Get keys from selection
371+ keyskeep , keysrem = self . GetSelection ( )
353372 self .wrapper .OnResults (keyskeep , keysrem )
354373
355374
0 commit comments