source: sasview/calculatorview/src/sans/perspectives/calculator/calculator.py @ 657490af

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 657490af was fdc3cb0, checked in by Jae Cho <jhjcho@…>, 13 years ago

titles for help windows

  • Property mode set to 100644
File size: 5.1 KB
Line 
1"""
2Calculator Module
3"""
4################################################################################
5#This software was developed by the University of Tennessee as part of the
6#Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
7#project funded by the US National Science Foundation.
8#
9#See the license text in license.txt
10#
11#copyright 2010, University of Tennessee
12################################################################################
13
14
15from sans.guiframe.plugin_base import PluginBase
16import logging
17
18class Plugin(PluginBase):
19    """
20    This class defines the interface for a Plugin class
21    for calculator perspective
22    """
23    def __init__(self, standalone=True):
24        PluginBase.__init__(self, name="Calculator", standalone=standalone)
25        # Log startup
26        logging.info("Calculator plug-in started")   
27        self.sub_menu = "Tool" 
28 
29    def help(self, evt):
30        """
31        Show a general help dialog.
32       
33        :TODO: replace the text with a nice image
34            provide more hint on the SLD calculator
35        """
36        from help_panel import  HelpWindow
37        frame = HelpWindow(None, -1) 
38        if hasattr(frame, "IsIconized"):
39            if not frame.IsIconized():
40                try:
41                    icon = self.parent.GetIcon()
42                    frame.SetIcon(icon)
43                except:
44                    pass 
45        frame.Show(True)
46
47    def get_tools(self):
48        """
49        Returns a set of menu entries for tools
50        """
51        kiessig_help = "Approximately computes the "
52        kiessig_help += "thickness of a shell or the size of "
53        kiessig_help += "particles \n from the width of a Kiessig fringe."
54        sld_help = "Computes the Scattering Length Density."
55        slit_length_help = "Computes the slit length from the beam profile."
56        resolution_help = "Approximately estimates the "
57        resolution_help += "resolution of Q in 2D based on the SANS "
58        resolution_help += "instrumental parameter values."
59        pyconsole_help = "Python Console."
60        #data_editor_help = "Meta Data Editor"
61        return [("SLD Calculator", sld_help, self.on_calculate_sld),
62                ("Slit Size Calculator", slit_length_help,
63                        self.on_calculate_slit_size),
64                ("Kiessig Thickness Calculator", 
65                        kiessig_help, self.on_calculate_kiessig),
66                          ("SANS Resolution Estimator", 
67                        resolution_help, self.on_calculate_resoltuion),
68                ("Python Shell", pyconsole_help, self.on_python_console)]
69             
70    def on_edit_data(self, event):
71        """
72        Edit meta data
73        """
74        from data_editor import DataEditorWindow
75        frame = DataEditorWindow(parent=self.parent, data=[],
76                                  title="Data Editor")
77        self.put_icon(frame)
78        frame.Show(True)
79        event.Skip()
80
81    def on_calculate_kiessig(self, event):
82        """
83        Compute the Kiessig thickness
84        """
85        from kiessig_calculator_panel import KiessigWindow
86        frame = KiessigWindow()
87        self.put_icon(frame)
88        frame.Show(True) 
89   
90    def on_calculate_sld(self, event):
91        """
92        Compute the scattering length density of molecula
93        """
94        from sld_panel import SldWindow
95        frame = SldWindow(base=self.parent)
96        self.put_icon(frame)
97        frame.Show(True) 
98       
99    def on_calculate_slit_size(self, event):
100        """
101        Compute the slit size a given data
102        """
103        from slit_length_calculator_panel import SlitLengthCalculatorWindow
104        frame = SlitLengthCalculatorWindow(parent=self.parent) 
105        self.put_icon(frame) 
106        frame.Show(True)
107       
108    def on_calculate_resoltuion(self, event):
109        """
110        Estimate the instrumental resolution
111        """
112        from resolution_calculator_panel import ResolutionWindow
113        frame = ResolutionWindow(parent=self.parent)
114        self.put_icon(frame)
115        frame.Show(True) 
116 
117        #def on_perspective(self, event):
118        """
119        Call back function for the perspective menu item.
120        We notify the parent window that the perspective
121        has changed.
122       
123        :param event: menu event
124       
125        """
126        #self.parent.set_perspective(self.perspective)
127        #if event != None:
128        #    event.Skip()
129    def on_python_console(self, event):
130        """
131        Open Python Console
132       
133        :param event: menu event
134        """
135        from pyconsole import PyConsole
136        frame = PyConsole(parent=self.parent)
137        self.put_icon(frame)
138        frame.Show(True) 
139   
140    def put_icon(self, frame):
141        """
142        Put icon in the frame title bar
143        """
144        if hasattr(frame, "IsIconized"):
145            if not frame.IsIconized():
146                try:
147                    icon = self.parent.GetIcon()
148                    frame.SetIcon(icon)
149                except:
150                    pass     
151 
152   
Note: See TracBrowser for help on using the repository browser.