Changeset 318b5bbb in sasview for calculatorview/src/sans/perspectives/calculator/model_editor.py
- Timestamp:
- Dec 18, 2012 8:55:24 AM (11 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:
- 6550b64
- Parents:
- 0203ade
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
calculatorview/src/sans/perspectives/calculator/model_editor.py
r657e52c r318b5bbb 11 11 import sys 12 12 import os 13 import math 13 14 from wx.py.editwindow import EditWindow 14 import subprocess15 15 16 16 if sys.platform.count("win32") > 0: … … 24 24 M_NAME = 'Model' 25 25 EDITOR_WIDTH = 800 26 EDITOR_HEIGTH = 7 2026 EDITOR_HEIGTH = 735 27 27 PANEL_WIDTH = 500 28 28 _BOX_WIDTH = 55 … … 530 530 self.warning = "" 531 531 self._description = "New Custom Model" 532 self.function_tcl = None 532 533 #self._default_save_location = os.getcwd() 533 534 self._do_layout() … … 546 547 self.param_sizer = wx.BoxSizer(wx.VERTICAL) 547 548 self.function_sizer = wx.BoxSizer(wx.VERTICAL) 549 self.func_horizon_sizer = wx.BoxSizer(wx.HORIZONTAL) 548 550 self.button_sizer = wx.BoxSizer(wx.HORIZONTAL) 549 551 self.msg_sizer = wx.BoxSizer(wx.HORIZONTAL) … … 592 594 """ 593 595 param_txt = wx.StaticText(self, -1, 'Fit Parameters (if any): ') 596 594 597 param_tip = "#Set the parameters and initial values.\n" 595 598 param_tip += "#Example:\n" … … 601 604 self.param_tcl.setDisplayLineNumbers(True) 602 605 self.param_tcl.SetToolTipString(param_tip) 606 603 607 self.param_sizer.AddMany([(param_txt, 0, wx.LEFT, 10), 604 608 (self.param_tcl, 1, wx.EXPAND|wx.ALL, 10)]) 605 606 609 607 610 def _layout_function(self): 608 611 """ … … 616 619 hint_function += " y = A + B * cos(2 * pi * x)\n" 617 620 hint_function += "return y\n" 621 math_txt = wx.StaticText(self, -1, '*Useful math functions: ') 622 math_combo = self._fill_math_combo() 623 618 624 id = wx.NewId() 619 625 self.function_tcl = EditWindow(self, id, wx.DefaultPosition, … … 621 627 self.function_tcl.setDisplayLineNumbers(True) 622 628 self.function_tcl.SetToolTipString(hint_function) 623 self.function_sizer.Add(function_txt, 0, wx.LEFT, 10) 629 630 self.func_horizon_sizer.Add(function_txt) 631 self.func_horizon_sizer.Add(math_txt, 0, wx.LEFT, 250) 632 self.func_horizon_sizer.Add(math_combo, 0, wx.LEFT, 10) 633 634 self.function_sizer.Add(self.func_horizon_sizer, 0, wx.LEFT, 10) 624 635 self.function_sizer.Add( self.function_tcl, 1, wx.EXPAND|wx.ALL, 10) 625 636 … … 682 693 self.SetSizer(self.main_sizer) 683 694 self.SetAutoLayout(True) 684 695 696 def _fill_math_combo(self): 697 """ 698 Fill up the math combo box 699 """ 700 self.math_combo = wx.ComboBox(self, -1, size=(100, -1), 701 style=wx.CB_READONLY) 702 for item in dir(math): 703 if item.count("_") < 1: 704 try: 705 exec "float(math.%s)"% item 706 self.math_combo.Append(str(item)) 707 except: 708 self.math_combo.Append(str(item) + "()" ) 709 self.math_combo.Bind(wx.EVT_COMBOBOX, self._on_math_select) 710 self.math_combo.SetSelection(0) 711 return self.math_combo 712 713 def _on_math_select(self, event): 714 """ 715 On math selection on ComboBox 716 """ 717 event.Skip() 718 label = self.math_combo.GetLabel() 719 self.function_tcl.SetFocus() 720 # Put the text at the cursor position 721 pos = self.function_tcl.GetCurrentPos() 722 self.function_tcl.InsertText(pos, label) 723 # Put the cursor at appropriate postion 724 length = len(label) 725 if label[-1] == ')': 726 length -= 1 727 f_pos = pos + length 728 self.function_tcl.GotoPos(f_pos) 729 685 730 def get_notes(self): 686 731 """ … … 1071 1116 ## Parameter details [units, min, max] 1072 1117 self.details = {} 1073 1118 ## Magnetic Panrameters 1119 self.magnetic_params = [] 1074 1120 # non-fittable parameters 1075 1121 self.non_fittable = p_model1.non_fittable … … 1105 1151 if not new_item in self.orientation_params: 1106 1152 self.orientation_params.append(new_item) 1153 ## magnetic params 1154 for item in self.p_model1.magnetic_params: 1155 new_item = "p1_" + item 1156 if not new_item in self.magnetic_params: 1157 self.magnetic_params.append(new_item) 1158 1159 for item in self.p_model2.magnetic_params: 1160 new_item = "p2_" + item 1161 if not new_item in self.magnetic_params: 1162 self.magnetic_params.append(new_item) 1107 1163 # get multiplicity if model provide it, else 1. 1108 1164 try:
Note: See TracChangeset
for help on using the changeset viewer.