Changeset 26d2d88 in sasview
- Timestamp:
- Mar 2, 2015 1:04:44 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:
- 788d4c3
- Parents:
- 460f5f2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/perspectives/calculator/kiessig_calculator_panel.py
r9654baf r26d2d88 2 2 This software was developed by the University of Tennessee as part of the 3 3 Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 4 project funded by the US National Science Foundation. 4 project funded by the US National Science Foundation. 5 5 6 6 See the license text in license.txt … … 13 13 14 14 from sas.guiframe.panel_base import PanelBase 15 from sas.calculator.kiessig_calculator import KiessigThicknessCalculator 15 from sas.calculator.kiessig_calculator import KiessigThicknessCalculator 16 16 from calculator_widgets import OutputTextCtrl 17 17 from calculator_widgets import InputTextCtrl 18 from sas.perspectives.calculator import calculator_widgets as widget 18 from sas.perspectives.calculator import calculator_widgets as widget 19 19 from sas.guiframe.documentation_window import DocumentationWindow 20 20 21 21 _BOX_WIDTH = 77 22 #Slit length panel size 22 #Slit length panel size 23 23 if sys.platform.count("win32") > 0: 24 24 PANEL_WIDTH = 500 … … 40 40 ## Flag to tell the AUI manager to put this panel in the center pane 41 41 CENTER_PANE = True 42 42 43 43 def __init__(self, parent, *args, **kwds): 44 44 wx.Panel.__init__(self, parent, *args, **kwds) 45 45 PanelBase.__init__(self) 46 #Font size 47 self.SetWindowVariant(variant=FONT_VARIANT) 46 #Font size 47 self.SetWindowVariant(variant=FONT_VARIANT) 48 48 # Object that receive status event 49 49 self.parent = parent … … 52 52 self.hint_sizer = None 53 53 self._do_layout() 54 54 55 55 def _define_structure(self): 56 56 """ … … 61 61 str("Kiessig Thickness Calculator")) 62 62 self.boxsizer_source = wx.StaticBoxSizer(self.box_source, 63 63 wx.VERTICAL) 64 64 self.dq_name_sizer = wx.BoxSizer(wx.HORIZONTAL) 65 65 self.thickness_size_sizer = wx.BoxSizer(wx.HORIZONTAL) 66 66 self.hint_sizer = wx.BoxSizer(wx.HORIZONTAL) 67 67 self.button_sizer = wx.BoxSizer(wx.HORIZONTAL) 68 68 69 69 def _layout_dq_name(self): 70 70 """ … … 74 74 dq_value = str(self.kiessig.get_deltaq()) 75 75 dq_unit_txt = wx.StaticText(self, -1, '[1/A]') 76 dq_name_txt = wx.StaticText(self, -1, 77 'Kiessig Fringe Width (Delta Q): ')76 dq_name_txt = wx.StaticText(self, -1, 77 'Kiessig Fringe Width (Delta Q): ') 78 78 self.dq_name_tcl = InputTextCtrl(self, -1, 79 79 size=(_BOX_WIDTH,-1)) … … 89 89 self.dq_name_sizer.AddMany([(dq_name_txt, 0, wx.LEFT, 15), 90 90 (self.dq_name_tcl, 0, wx.LEFT, 15), 91 (dq_unit_txt,0, wx.LEFT, 10), 92 (self.compute_button, 0, wx.LEFT, 30)]) 91 (dq_unit_txt, 0, wx.LEFT, 10), 92 (self.compute_button, 0, wx.LEFT, 30)]) 93 93 94 def _layout_thickness_size(self): 94 95 """ … … 96 97 """ 97 98 thick_unit = '['+self.kiessig.get_thickness_unit() +']' 98 thickness_size_txt = wx.StaticText(self, -1, 99 thickness_size_txt = wx.StaticText(self, -1, 99 100 'Thickness (or Diameter): ') 100 self.thickness_size_tcl = OutputTextCtrl(self, -1, 101 self.thickness_size_tcl = OutputTextCtrl(self, -1, 101 102 size=(_BOX_WIDTH,-1)) 102 103 thickness_size_hint = " Estimated Size in Real Space" 103 104 self.thickness_size_tcl.SetToolTipString(thickness_size_hint) 104 105 thickness_size_unit_txt = wx.StaticText(self, -1, thick_unit) 105 106 106 107 self.thickness_size_sizer.AddMany([(thickness_size_txt, 0, wx.LEFT, 15), 107 (self.thickness_size_tcl, 0, wx.LEFT, 15),108 (thickness_size_unit_txt, 0, wx.LEFT, 10)])109 108 (self.thickness_size_tcl, 0, wx.LEFT, 15), 109 (thickness_size_unit_txt, 0, wx.LEFT, 10)]) 110 110 111 def _layout_hint(self): 111 112 """ … … 119 120 self.hint_txt = wx.StaticText(self, -1, hint_msg) 120 121 self.hint_sizer.AddMany([(self.hint_txt, 0, wx.LEFT, 15)]) 121 122 122 123 def _layout_button(self): 123 124 """ … … 125 126 """ 126 127 id = wx.NewId() 127 self.bt_help = wx.Button(self, id, 'HELP')128 self.bt_help = wx.Button(self, id, 'HELP') 128 129 self.bt_help.Bind(wx.EVT_BUTTON, self.on_help) 129 130 self.bt_help.SetToolTipString("Help using the Kiessig fringe calculator.") 130 131 131 self.bt_close = wx.Button(self, wx.ID_CANCEL, 'Close')132 self.bt_close = wx.Button(self, wx.ID_CANCEL, 'Close') 132 133 self.bt_close.Bind(wx.EVT_BUTTON, self.on_close) 133 134 self.bt_close.SetToolTipString("Close this window.") 134 135 self.button_sizer.AddMany([(self.bt_help, 0, wx.LEFT, 260), 135 136 (self.bt_close, 0, wx.LEFT, 20)]) 136 137 137 138 def _do_layout(self): 138 139 """ … … 145 146 self._layout_button() 146 147 self.boxsizer_source.AddMany([(self.dq_name_sizer, 0, 147 148 (self.thickness_size_sizer, 0,149 wx.EXPAND|wx.TOP|wx.BOTTOM, 5),150 (self.hint_sizer, 0,151 wx.EXPAND|wx.TOP|wx.BOTTOM, 5)])148 wx.EXPAND|wx.TOP|wx.BOTTOM, 5), 149 (self.thickness_size_sizer, 0, 150 wx.EXPAND|wx.TOP|wx.BOTTOM, 5), 151 (self.hint_sizer, 0, 152 wx.EXPAND|wx.TOP|wx.BOTTOM, 5)]) 152 153 self.main_sizer.AddMany([(self.boxsizer_source, 0, wx.ALL, 10), 153 154 154 (self.button_sizer, 0, 155 wx.EXPAND|wx.TOP|wx.BOTTOM, 5)]) 155 156 self.SetSizer(self.main_sizer) 156 157 self.SetAutoLayout(True) 157 158 158 def on_help(self, event): 159 def on_help(self, event): 159 160 """ 160 161 Bring up the Kiessig fringe calculator Documentation whenever 161 the HELP button is clicked. 162 162 the HELP button is clicked. 163 163 Calls DocumentationWindow with the path of the location within the 164 documentation tree (after /doc/ ....". Note that when using old 165 versions of Wx (before 2.9) and thus not the release version of 166 installers, the help comes up at the top level of the file as 164 documentation tree (after /doc/ ....". Note that when using old 165 versions of Wx (before 2.9) and thus not the release version of 166 installers, the help comes up at the top level of the file as 167 167 webbrowser does not pass anything past the # to the browser when it is 168 168 running "file:///...." 169 169 170 170 :param evt: Triggers on clicking the help button 171 171 """ 172 173 172 _TreeLocation = "user/perspectives/calculator/kiessig_calculator_help.html" 174 _doc_viewer = DocumentationWindow(self, -1, \ 175 _TreeLocation,"Density/Volume Calculator Help") 173 _doc_viewer = DocumentationWindow(self, -1, 174 _TreeLocation, 175 "Density/Volume Calculator Help") 176 176 177 177 def on_close(self, event): … … 182 182 if event is not None: 183 183 event.Skip() 184 184 185 185 def on_compute(self, event): 186 186 """ … … 197 197 # set tcl 198 198 self.thickness_size_tcl.SetValue(str(thickness)) 199 199 200 200 def format_number(self, value=None): 201 201 """ 202 Return a float in a standardized, human-readable formatted string 203 """ 204 try: 202 Return a float in a standardized, human-readable formatted string 203 """ 204 try: 205 205 value = float(value) 206 206 except: … … 209 209 210 210 output = "%-7.4g" % value 211 return output.lstrip().rstrip() 211 return output.lstrip().rstrip() 212 212 213 213 def _onparamEnter(self, event = None): … … 216 216 """ 217 217 self.on_compute(event) 218 218 219 219 class KiessigWindow(widget.CHILD_FRAME): 220 220 def __init__(self, parent=None, manager=None, … … 239 239 self.Destroy() 240 240 241 242 if __name__ == "__main__": 241 if __name__ == "__main__": 243 242 app = wx.PySimpleApp() 244 243 widget.CHILD_FRAME = wx.Frame 245 frame = KiessigWindow() 244 frame = KiessigWindow() 246 245 frame.Show(True) 247 app.MainLoop() 246 app.MainLoop()
Note: See TracChangeset
for help on using the changeset viewer.