Changeset 37d461c in sasview for src/sas/sasgui/guiframe
- Timestamp:
- Apr 10, 2017 6:40:40 AM (8 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 6267876
- Parents:
- 3f75203
- git-author:
- Jeff Krzywon <krzywon@…> (04/10/17 06:40:40)
- git-committer:
- krzywon <krzywon@…> (04/10/17 06:40:40)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/guiframe/local_perspectives/plotting/parameters_panel_boxsum.py
r39f0bf4 r37d461c 1 1 import wx 2 2 import wx.lib.newevent 3 #from copy import deepcopy 3 from parameters_panel_slicer import SlicerParameterPanel 4 4 from sas.sasgui.guiframe.utils import format_number 5 from sas.sasgui.guiframe. events import SlicerParameterEvent6 from sas.sasgui.guiframe.events import EVT_SLICER_PARS7 from sas.sasgui.guiframe.events import EVT_SLICER 5 from sas.sasgui.guiframe.panel_base import PanelBase 6 from sas.sasgui.guiframe.events import (SlicerParameterEvent, EVT_SLICER_PARS, 7 EVT_SLICER) 8 8 9 from sas.sasgui.guiframe.panel_base import PanelBase10 9 11 10 class SlicerPanel(wx.Panel, PanelBase): … … 13 12 Panel class to show the slicer parameters 14 13 """ 15 #TODO: show units 16 #TODO: order parameters properly 17 ## Internal name for the AUI manager 14 # Internal name for the AUI manager 18 15 window_name = "Slicer panel" 19 # #Title to appear on top of the window16 # Title to appear on top of the window 20 17 window_caption = "Slicer Panel" 21 18 CENTER_PANE = False … … 25 22 wx.Panel.__init__(self, parent, id, *args, **kwargs) 26 23 PanelBase.__init__(self) 27 # #Initialization of the class24 # Initialization of the class 28 25 self.base = base 29 26 if params is None: … … 37 34 self.bck = wx.GridBagSizer(5, 5) 38 35 self.SetSizer(self.bck) 39 if type == None and params ==None:36 if type is None and params is None: 40 37 label = "Right-click on 2D plot for slicer options" 41 38 title = wx.StaticText(self, -1, label, style=wx.ALIGN_LEFT) … … 44 41 else: 45 42 self.set_slicer(type, params) 46 ## Bindings 47 self.parent.Bind(EVT_SLICER, self.onEVT_SLICER) 48 self.parent.Bind(EVT_SLICER_PARS, self.onParamChange) 49 50 def onEVT_SLICER(self, event): 51 """ 52 Process EVT_SLICER events 53 When the slicer changes, update the panel 54 55 :param event: EVT_SLICER event 56 57 """ 58 event.Skip() 59 if event.obj_class == None: 60 self.set_slicer(None, None) 61 else: 62 self.set_slicer(event.type, event.params) 43 # Bindings 44 self.parent.Bind(EVT_SLICER, SlicerParameterPanel.on_evt_slicer) 45 self.parent.Bind(EVT_SLICER_PARS, SlicerParameterPanel.on_param_change) 63 46 64 47 def set_slicer(self, type, params): … … 68 51 self.bck.Clear(True) 69 52 self.type = type 70 if type ==None:53 if type is None: 71 54 label = "Right-click on 2D plot for slicer options" 72 55 title = wx.StaticText(self, -1, label, style=wx.ALIGN_LEFT) … … 84 67 keys.sort() 85 68 for item in keys: 86 if not item.lower() in ["num_points", "avg", "avg_error", "sum", "sum_error"]: 69 if not item.lower() in ["num_points", "avg", "avg_error", "sum", 70 "sum_error"]: 87 71 n += 1 88 72 text = wx.StaticText(self, -1, item, style=wx.ALIGN_LEFT) 89 73 self.bck.Add(text, (n - 1, 0), 90 flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL, border=15) 74 flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 75 border=15) 91 76 ctl = wx.TextCtrl(self, -1, size=(80, 20), 92 77 style=wx.TE_PROCESS_ENTER) … … 95 80 ctl.SetToolTipString(hint_msg) 96 81 ctl.SetValue(str(format_number(params[item]))) 97 self.Bind(wx.EVT_TEXT_ENTER, self.on TextEnter)98 ctl.Bind(wx.EVT_SET_FOCUS, self.on SetFocus)99 ctl.Bind(wx.EVT_KILL_FOCUS, self.on TextEnter)82 self.Bind(wx.EVT_TEXT_ENTER, self.on_text_enter) 83 ctl.Bind(wx.EVT_SET_FOCUS, self.on_set_focus) 84 ctl.Bind(wx.EVT_KILL_FOCUS, self.on_text_enter) 100 85 self.parameters.append([item, ctl]) 101 self.bck.Add(ctl, (n - 1, 1), flag=wx.TOP | wx.BOTTOM, border=0) 86 self.bck.Add(ctl, (n - 1, 1), flag=wx.TOP | wx.BOTTOM, 87 border=0) 102 88 for item in keys: 103 if item.lower() in ["num_points", "avg", "avg_error", "sum", "sum_error"]: 89 if item.lower() in ["num_points", "avg", "avg_error", "sum", 90 "sum_error"]: 104 91 n += 1 105 text = wx.StaticText(self, -1, item + ": ", style=wx.ALIGN_LEFT) 106 self.bck.Add(text, (n - 1, 0), flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 92 text = wx.StaticText(self, -1, item + ": ", 93 style=wx.ALIGN_LEFT) 94 self.bck.Add(text, (n - 1, 0), 95 flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 107 96 border=15) 108 97 ctl = wx.StaticText(self, -1, … … 110 99 style=wx.ALIGN_LEFT) 111 100 ctl.SetToolTipString("Result %s" % item) 112 self.bck.Add(ctl, (n - 1, 1), flag=wx.TOP | wx.BOTTOM, border=0) 101 self.bck.Add(ctl, (n - 1, 1), flag=wx.TOP | wx.BOTTOM, 102 border=0) 113 103 self.bck.Layout() 114 104 self.Layout() 115 p sizer = self.parent.GetSizer()116 if p sizer !=None:117 p sizer.Layout()105 p_sizer = self.parent.GetSizer() 106 if p_sizer is not None: 107 p_sizer.Layout() 118 108 119 def on SetFocus(self, evt):109 def on_set_focus(self, evt): 120 110 """ 121 111 Highlight the txtcrtl … … 126 116 # Select the whole control, after this event resolves 127 117 wx.CallAfter(widget.SetSelection, -1, -1) 128 return129 118 130 def onParamChange(self, evt): 131 """ 132 Receive and event and reset the text field contained in self.parameters 133 134 """ 135 evt.Skip() 136 for item in self.parameters: 137 if item[0] in evt.params: 138 item[1].SetValue(format_number(evt.params[item[0]])) 139 item[1].Refresh() 140 141 def onTextEnter(self, evt): 119 def on_text_enter(self, evt): 142 120 """ 143 121 Parameters have changed … … 149 127 try: 150 128 params[item[0]] = float(item[1].GetValue()) 151 item[1].SetBackgroundColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)) 129 item[1].SetBackgroundColour(wx.SystemSettings_GetColour( 130 wx.SYS_COLOUR_WINDOW)) 152 131 item[1].Refresh() 153 132 except: … … 155 134 item[1].SetBackgroundColour("pink") 156 135 item[1].Refresh() 157 158 if has_error == False: 136 if not has_error: 159 137 # Post parameter event 160 # #base is guiframe is this case138 # base is guiframe is this case 161 139 event = SlicerParameterEvent(type=self.type, params=params) 162 140 wx.PostEvent(self.base, event) … … 166 144 On Close Event 167 145 """ 168 ID= self.uid169 self.parent.delete_panel( ID)146 uid = self.uid 147 self.parent.delete_panel(uid) 170 148 self.frame.Destroy()
Note: See TracChangeset
for help on using the changeset viewer.