Changeset 33c671e in sasview
- Timestamp:
- Jun 25, 2012 1:17:51 PM (13 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:
- 5a5bb29
- Parents:
- 0a9686d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
calculatorview/src/sans/perspectives/calculator/data_operator.py
r19b9e43 r33c671e 17 17 #Control panel width 18 18 if sys.platform.count("win32") > 0: 19 PANEL_WIDTH = 7 8019 PANEL_WIDTH = 790 20 20 PANEL_HEIGTH = 370 21 21 FONT_VARIANT = 0 … … 24 24 else: 25 25 _BOX_WIDTH = 230 26 PANEL_WIDTH = 89026 PANEL_WIDTH = 900 27 27 PANEL_HEIGTH = 430 28 28 FONT_VARIANT = 1 … … 100 100 self.data1_cbox = wx.ComboBox(self, -1, size=(_BOX_WIDTH, 25), 101 101 style=wx.CB_READONLY) 102 self.operator_cbox = wx.ComboBox(self, -1, size=( 50, -1),102 self.operator_cbox = wx.ComboBox(self, -1, size=(70, 25), 103 103 style=wx.CB_READONLY) 104 104 operation_tip = "Add: +, Subtract: -, " … … 117 117 style=wx.NO_BORDER) 118 118 self.operator_pic = SmallPanel(self, -1, True, 119 '+', size=( 50, _BOX_WIDTH),119 '+', size=(70, _BOX_WIDTH), 120 120 style=wx.NO_BORDER) 121 121 self.data2_pic = SmallPanel(self, -1, True, … … 150 150 self.data2_cbox.Show(True) 151 151 152 self. numberctr.Show(False)153 152 self._show_numctrl(self.numberctr, False) 153 154 154 wx.EVT_TEXT_ENTER(self.data_namectr, -1, self.on_name) 155 155 wx.EVT_TEXT_ENTER(self.numberctr, -1, self.on_number) … … 157 157 wx.EVT_COMBOBOX(self.operator_cbox, -1, self.on_select_operator) 158 158 wx.EVT_COMBOBOX(self.data2_cbox, -1, self.on_select_data2) 159 159 160 def _show_numctrl(self, ctrl, enable=True): 161 """ 162 Show/Hide on Win 163 Enable/Disable on MAC 164 """ 165 if ON_MAC: 166 ctrl.Enable(enable) 167 ctrl.GetChildren()[0].SetBackGroundColor(self.GetBackGroundColor()) 168 else: 169 ctrl.Show(enable) 170 160 171 def on_name(self, event=None): 161 172 """ … … 165 176 event.Skip() 166 177 item = event.GetEventObject() 167 item.SetBackgroundColour('white') 178 if item.IsEnabled(): 179 self._set_textctrl_color(item, 'white') 180 else: 181 self._set_textctrl_color(item, self.GetBackgroundColour()) 168 182 text = item.GetLabel().strip() 169 183 self._check_newname(text) … … 181 195 state_list = self.get_datalist().values() 182 196 if text in [str(state.data.name) for state in state_list]: 183 self. data_namectr.SetBackgroundColour('pink')197 self._set_textctrl_color(self.data_namectr, 'pink') 184 198 msg = "DataOperation: The name already exists." 185 199 if len(text) == 0: 186 self. data_namectr.SetBackgroundColour('pink')200 self._set_textctrl_color(self.data_namectr, 'pink') 187 201 msg = "DataOperation: Type the data name first." 188 202 if self._notes: 189 203 self.send_warnings(msg, 'error') 204 205 self.Refresh() 206 207 def _set_textctrl_color(self, ctrl, color): 208 """ 209 Set TextCtrl color 210 """ 211 if ON_MAC: 212 ctrl.GetChildren()[0].SetBackgroundColour(color) 213 else: 214 ctrl.SetBackgroundColour(color) 190 215 self.name_sizer.Layout() 191 self.Refresh() 192 216 193 217 def on_number(self, event=None): 194 218 """ … … 198 222 event.Skip() 199 223 self.send_warnings('') 200 self.numberctr.SetBackgroundColour('white') 224 if self.numberctr.IsEnabled(): 225 self._set_textctrl_color(self.numberctr, 'white') 226 else: 227 self._set_textctrl_color(self.numberctr, self.GetBackgroundColour()) 228 201 229 item = event.GetEventObject() 202 230 text = item.GetLabel().strip() … … 206 234 self.data2_cbox.SetClientData(pos, val) 207 235 except: 208 self. numberctr.SetBackgroundColour('pink')236 self._set_textctrl_color(self.numberctr, 'pink') 209 237 msg = "DataOperation: Number requires a float number." 210 238 self.send_warnings(msg, 'error') … … 244 272 self.send_warnings('') 245 273 item = event.GetEventObject() 246 text = item.Get Label().strip()274 text = item.GetValue().strip() 247 275 self.put_text_pic(self.operator_pic, content=text) 248 276 self.check_data_inputs() … … 260 288 item = event.GetEventObject() 261 289 text = item.GetLabel().strip().lower() 262 self. numberctr.Show(text=='number')290 self._show_numctrl(self.numberctr, text=='number') 263 291 264 292 pos = item.GetSelection() 265 293 data = item.GetClientData(pos) 266 294 content = "?" 267 if not self.numberctr.IsShown():295 if not (self.numberctr.IsShown() and self.numberctr.IsEnabled()): 268 296 if data == None: 269 297 content = "?" … … 278 306 data = content 279 307 except: 308 self._set_textctrl_color(self.numberctr, 'pink') 280 309 content = "?" 281 310 data = None … … 300 329 Check data1 and data2 whether or not they are ready for operation 301 330 """ 302 self. data1_cbox.SetBackgroundColour('white')303 self. data2_cbox.SetBackgroundColour('white')331 self._set_textctrl_color(self.data1_cbox, 'white') 332 self._set_textctrl_color(self.data2_cbox, 'white') 304 333 flag = False 305 334 pos1 = self.data1_cbox.GetCurrentSelection() … … 314 343 return flag 315 344 if self.numberctr.IsShown(): 316 self.numberctr.SetBackgroundColour('white') 345 if self.numberctr.IsEnabled(): 346 self._set_textctrl_color(self.numberctr, 'white') 347 else: 348 self._set_textctrl_color(self.numberctr, 349 self.GetBackgroundColour()) 317 350 try: 318 351 float(data2) … … 321 354 msg += "a float number." 322 355 self.send_warnings(msg, 'error') 323 self. numberctr.SetBackgroundColour('pink')356 self._set_textctrl_color(self.numberctr, 'pink') 324 357 self.output = None 325 358 return flag … … 327 360 msg = "DataOperation: Number requires a float number." 328 361 self.send_warnings(msg, 'error') 329 self. numberctr.SetBackgroundColour('pink')362 self._set_textctrl_color(self.numberctr, 'pink') 330 363 self.output = None 331 364 return flag 332 365 elif data1.__class__.__name__ != data2.__class__.__name__: 333 self. data1_cbox.SetBackgroundColour('pink')334 self. data2_cbox.SetBackgroundColour('pink')366 self._set_textctrl_color(self.data1_cbox, 'pink') 367 self._set_textctrl_color(self.data1_cbox, 'pink') 335 368 msg = "DataOperation: Data types must be same." 336 369 self.send_warnings(msg, 'error') … … 341 374 except: 342 375 self._check_newname() 343 self. data1_cbox.SetBackgroundColour('pink')344 self. data2_cbox.SetBackgroundColour('pink')376 self._set_textctrl_color(self.data1_cbox, 'pink') 377 self._set_textctrl_color(self.data2_cbox, 'pink') 345 378 msg = "DataOperation: Data types must be same." 346 379 self.send_warnings(msg, 'error') … … 450 483 pos3 = self.data2_cbox.Append("Number") 451 484 val = None 452 if self.numberctr.IsShown():485 if (self.numberctr.IsShown() and self.numberctr.IsEnabled()): 453 486 try: 454 487 val = float(self.numberctr.GetValue()) … … 465 498 pos3 = self.data2_cbox.Append('Number') 466 499 val = None 467 if self.numberctr.IsShown():500 if (self.numberctr.IsShown() and self.numberctr.IsEnabled()): 468 501 try: 469 502 val = float(self.numberctr.GetValue()) … … 523 556 self.data_namectr.SetBackgroundColour('white') 524 557 state_list = self.get_datalist().values() 525 name = self.data_namectr.Get Label().strip()558 name = self.data_namectr.GetValue().strip() 526 559 if name in [str(state.data.name) for state in state_list]: 527 self. data_namectr.SetBackgroundColour('pink')560 self._set_textctrl_color(self.data_namectr, 'pink') 528 561 msg = "The Output Data Name already exists... " 529 562 wx.MessageBox(msg, 'Error') 530 563 return 531 564 if name == '': 532 s elf.data_namectr.SetBackgroundColour('pink')565 sself._set_textctrl_color(self.data_namectr, 'pink') 533 566 msg = "Please type the output data name first... " 534 567 wx.MessageBox(msg, 'Error')
Note: See TracChangeset
for help on using the changeset viewer.