Changeset b40ad40 in sasview for src/sas/guiframe/local_perspectives/plotting/slicerpanel.py
- Timestamp:
- Mar 5, 2015 4:53:03 PM (10 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.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- c4f6851
- Parents:
- c039589
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/guiframe/local_perspectives/plotting/slicerpanel.py
r27ab091 rb40ad40 1 2 3 1 import wx 4 2 import wx.lib.newevent … … 13 11 class SlicerPanel(wx.Panel, PanelBase): 14 12 """ 15 Panel class to show the slicer parameters 13 Panel class to show the slicer parameters 16 14 """ 17 15 #TODO: show units … … 22 20 window_caption = "Slicer Panel" 23 21 CENTER_PANE = False 24 22 25 23 def __init__(self, parent, id=-1, type=None, base=None, 26 params=None, *args, **kwargs):24 params=None, *args, **kwargs): 27 25 wx.Panel.__init__(self, parent, id, *args, **kwargs) 28 26 PanelBase.__init__(self) 29 ## Initialization of the class 27 ## Initialization of the class 30 28 self.base = base 31 29 if params is None: … … 39 37 self.bck = wx.GridBagSizer(5, 5) 40 38 self.SetSizer(self.bck) 41 if type == None and params == None: 42 label = "Right-click on 2D plot for slicer options" 39 if type == None and params == None: 40 label = "Right-click on 2D plot for slicer options" 43 41 title = wx.StaticText(self, -1, label, style=wx.ALIGN_LEFT) 44 self.bck.Add(title, (0, 0), (1, 2), 45 flag=wx.LEFT |wx.ALIGN_CENTER_VERTICAL, border=15)42 self.bck.Add(title, (0, 0), (1, 2), 43 flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL, border=15) 46 44 else: 47 45 self.set_slicer(type, params) … … 54 52 Process EVT_SLICER events 55 53 When the slicer changes, update the panel 56 54 57 55 :param event: EVT_SLICER event 58 56 59 57 """ 60 58 event.Skip() 61 59 if event.obj_class == None: 62 self.set_slicer(None, None) 60 self.set_slicer(None, None) 63 61 else: 64 62 self.set_slicer(event.type, event.params) 65 63 66 64 def set_slicer(self, type, params): 67 65 """ 68 66 Rebuild the panel 69 67 """ 70 self.bck.Clear(True) 71 self.type = type 68 self.bck.Clear(True) 69 self.type = type 72 70 if type == None: 73 71 label = "Right-click on 2D plot for slicer options" 74 72 title = wx.StaticText(self, -1, label, style=wx.ALIGN_LEFT) 75 self.bck.Add(title, (0, 0), (1, 2), 76 flag=wx.LEFT |wx.ALIGN_CENTER_VERTICAL, border=15)73 self.bck.Add(title, (0, 0), (1, 2), 74 flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL, border=15) 77 75 else: 78 76 title_text = str(type) + "Parameters" 79 title = wx.StaticText(self, -1, title_text, 77 title = wx.StaticText(self, -1, title_text, 80 78 style=wx.ALIGN_LEFT) 81 self.bck.Add(title, (0, 0), (1, 2), 82 flag=wx.LEFT |wx.ALIGN_CENTER_VERTICAL, border=15)79 self.bck.Add(title, (0, 0), (1, 2), 80 flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL, border=15) 83 81 n = 1 84 82 self.parameters = [] … … 86 84 keys.sort() 87 85 for item in keys: 88 if not item.lower() in ["num_points", "avg", "avg_error", "sum", 89 "sum_error"]: 86 if not item.lower() in ["num_points", "avg", "avg_error", "sum", "sum_error"]: 90 87 n += 1 91 88 text = wx.StaticText(self, -1, item, style=wx.ALIGN_LEFT) 92 self.bck.Add(text, (n -1, 0),93 flag=wx.LEFT|wx.ALIGN_CENTER_VERTICAL, border=15)94 ctl = wx.TextCtrl(self, -1, size=(80, 20), 89 self.bck.Add(text, (n - 1, 0), 90 flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL, border=15) 91 ctl = wx.TextCtrl(self, -1, size=(80, 20), 95 92 style=wx.TE_PROCESS_ENTER) 96 93 hint_msg = "Modify the value of %s to change " % item … … 102 99 ctl.Bind(wx.EVT_KILL_FOCUS, self.onTextEnter) 103 100 self.parameters.append([item, ctl]) 104 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, border=0) 105 102 for item in keys: 106 if item.lower() in ["num_points", "avg", "avg_error", "sum", 107 "sum_error"]: 103 if item.lower() in ["num_points", "avg", "avg_error", "sum", "sum_error"]: 108 104 n += 1 109 text = wx.StaticText(self, -1, item + ": ", 110 style=wx.ALIGN_LEFT) 111 self.bck.Add(text, (n-1, 0), 112 flag=wx.LEFT|wx.ALIGN_CENTER_VERTICAL, 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, 113 107 border=15) 114 ctl = wx.StaticText(self, -1, 108 ctl = wx.StaticText(self, -1, 115 109 str(format_number(params[item])), 116 110 style=wx.ALIGN_LEFT) 117 111 ctl.SetToolTipString("Result %s" % item) 118 self.bck.Add(ctl, (n -1, 1), flag=wx.TOP|wx.BOTTOM, border=0)112 self.bck.Add(ctl, (n - 1, 1), flag=wx.TOP | wx.BOTTOM, border=0) 119 113 self.bck.Layout() 120 #self.bck.Fit(self)121 114 self.Layout() 122 115 psizer = self.parent.GetSizer() 123 116 if psizer != None: 124 117 psizer.Layout() 125 118 126 119 def onSetFocus(self, evt): 127 120 """ … … 134 127 wx.CallAfter(widget.SetSelection, -1, -1) 135 128 return 136 129 137 130 def onParamChange(self, evt): 138 131 """ 139 132 Receive and event and reset the text field contained in self.parameters 140 133 141 134 """ 142 135 evt.Skip() 143 for item in self.parameters: 136 for item in self.parameters: 144 137 if item[0] in evt.params: 145 138 item[1].SetValue(format_number(evt.params[item[0]])) 146 139 item[1].Refresh() 147 148 def onTextEnter(self, evt): 140 141 def onTextEnter(self, evt): 149 142 """ 150 143 Parameters have changed … … 156 149 try: 157 150 params[item[0]] = float(item[1].GetValue()) 158 item[1].SetBackgroundColour( 159 wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)) 151 item[1].SetBackgroundColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)) 160 152 item[1].Refresh() 161 153 except: … … 163 155 item[1].SetBackgroundColour("pink") 164 156 item[1].Refresh() 165 157 166 158 if has_error == False: 167 159 # Post parameter event … … 175 167 """ 176 168 ID = self.uid 177 self.parent.delete_panel(ID) 169 self.parent.delete_panel(ID) 178 170 self.frame.Destroy()
Note: See TracChangeset
for help on using the changeset viewer.