source: sasview/sansview/sansview.py @ df7a7e3

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 df7a7e3 was df7a7e3, checked in by Mathieu Doucet <doucetm@…>, 12 years ago

merging category branch

  • Property mode set to 100644
File size: 4.8 KB
Line 
1
2################################################################################
3#This software was developed by the University of Tennessee as part of the
4#Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
5#project funded by the US National Science Foundation.
6#
7#See the license text in license.txt
8#
9#copyright 2009, University of Tennessee
10################################################################################
11import os
12import logging
13from shutil import copy
14logging.basicConfig(level=logging.INFO,
15                    format='%(asctime)s %(levelname)s %(message)s',
16                    filename=os.path.join(os.path.expanduser("~"),'sasview.log'))
17
18import wx
19import sys
20# The below will make sure that sasview application uses the matplotlib font
21# bundled with sasview.
22if hasattr(sys, 'frozen'):
23    mplconfigdir = os.path.join(os.path.expanduser("~"), '.matplotlib')
24    if not os.path.exists(mplconfigdir):
25        os.mkdir(mplconfigdir)
26    os.environ['MPLCONFIGDIR'] = mplconfigdir
27    if sys.version_info < (2, 7):
28        reload(sys)
29    sys.setdefaultencoding("iso-8859-1")
30from sans.guiframe import gui_manager
31from sans.guiframe.gui_style import GUIFRAME
32from welcome_panel import WelcomePanel
33# For py2exe, import config here
34import local_config
35PLUGIN_MODEL_DIR = 'plugin_models'
36APP_NAME = 'SasView'
37def run():
38    sys.path.append(os.path.join("..","..",".."))
39    from multiprocessing import freeze_support
40    freeze_support()
41    sasview = SasView()
42       
43class SasViewApp(gui_manager.ViewApp):
44    """
45    """
46 
47
48class SasView():
49    """
50    """
51    def __init__(self):
52        """
53        """
54        #from gui_manager import ViewApp
55        self.gui = SasViewApp(0) 
56        # Set the application manager for the GUI
57        self.gui.set_manager(self)
58        # Add perspectives to the basic application
59        # Additional perspectives can still be loaded
60        # dynamically
61        # Note: py2exe can't find dynamically loaded
62        # modules. We load the fitting module here
63        # to ensure a complete Windows executable build.
64       
65        # Fitting perspective
66        try:
67            import sans.perspectives.fitting as module   
68            fitting_plug = module.Plugin()
69            self.gui.add_perspective(fitting_plug)
70        except Exception as inst:
71            logging.error("Fitting problems: " + str(inst))
72            logging.error("%s: could not find Fitting plug-in module"% APP_NAME) 
73            logging.error(sys.exc_value) 
74           
75        # P(r) perspective
76        try:
77            import sans.perspectives.pr as module   
78            pr_plug = module.Plugin(standalone=False)
79            self.gui.add_perspective(pr_plug)
80        except:
81            logging.error("%s: could not find P(r) plug-in module"% APP_NAME)
82            logging.error(sys.exc_value) 
83       
84        #Invariant perspective
85        try:
86            import sans.perspectives.invariant as module   
87            invariant_plug = module.Plugin(standalone=False)
88            self.gui.add_perspective(invariant_plug)
89        except:
90            raise
91            logging.error("%s: could not find Invariant plug-in module"% \
92                          APP_NAME)
93            logging.error(sys.exc_value) 
94       
95        #Calculator perspective   
96        try:
97            import sans.perspectives.calculator as module   
98            calculator_plug = module.Plugin(standalone=False)
99            self.gui.add_perspective(calculator_plug)
100        except:
101            logging.error("%s: could not find Calculator plug-in module"% \
102                                                        APP_NAME)
103            logging.error(sys.exc_value) 
104
105        # initialize category stuff
106        user_file = os.path.join(os.path.expanduser("~"),
107                                 'serialized_categories.p')
108       
109        if not os.path.isfile(user_file): 
110            # either first time starting sansview or the
111            # user has deleted their category file
112            my_dir = os.path.dirname(os.path.abspath(__file__))
113            default_file = os.path.join(my_dir, '..',
114                                        'sansmodels',
115                                        'default_categories.p' )
116            copy(default_file, user_file)
117
118           
119        # Add welcome page
120        self.gui.set_welcome_panel(WelcomePanel)
121     
122        # Build the GUI
123        self.gui.build_gui()
124        # delete unused model folder   
125        self.gui.clean_plugin_models(PLUGIN_MODEL_DIR)
126        # Start the main loop
127        self.gui.MainLoop() 
128       
129
130
131if __name__ == "__main__": 
132    from multiprocessing import freeze_support
133    freeze_support()
134    #Process(target=SasView).start()
135    sasview = SasView()
136
137   
Note: See TracBrowser for help on using the repository browser.