[fa597990] | 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 | ################################################################################ |
---|
[6bdf6ae] | 11 | import os |
---|
| 12 | import logging |
---|
[df7a7e3] | 13 | from shutil import copy |
---|
[6bdf6ae] | 14 | logging.basicConfig(level=logging.INFO, |
---|
| 15 | format='%(asctime)s %(levelname)s %(message)s', |
---|
[ea5fa58] | 16 | filename=os.path.join(os.path.expanduser("~"), |
---|
| 17 | 'sasview.log')) |
---|
[fa597990] | 18 | |
---|
| 19 | import wx |
---|
| 20 | import sys |
---|
[c329f4d] | 21 | # The below will make sure that sasview application uses the matplotlib font |
---|
| 22 | # bundled with sasview. |
---|
[fa597990] | 23 | if hasattr(sys, 'frozen'): |
---|
[709b1dc] | 24 | mplconfigdir = os.path.join(os.path.expanduser("~"), '.matplotlib') |
---|
[fa597990] | 25 | if not os.path.exists(mplconfigdir): |
---|
| 26 | os.mkdir(mplconfigdir) |
---|
| 27 | os.environ['MPLCONFIGDIR'] = mplconfigdir |
---|
[5559171] | 28 | if sys.version_info < (2, 7): |
---|
| 29 | reload(sys) |
---|
[270cc72e] | 30 | sys.setdefaultencoding("iso-8859-1") |
---|
[fa597990] | 31 | from sans.guiframe import gui_manager |
---|
| 32 | from sans.guiframe.gui_style import GUIFRAME |
---|
| 33 | from welcome_panel import WelcomePanel |
---|
| 34 | # For py2exe, import config here |
---|
| 35 | import local_config |
---|
[19e614a] | 36 | PLUGIN_MODEL_DIR = 'plugin_models' |
---|
[c329f4d] | 37 | APP_NAME = 'SasView' |
---|
[ca6481c] | 38 | def run(): |
---|
[0bc2ed1] | 39 | sys.path.append(os.path.join("..","..","..")) |
---|
[ca6481c] | 40 | from multiprocessing import freeze_support |
---|
| 41 | freeze_support() |
---|
[c329f4d] | 42 | sasview = SasView() |
---|
[ca6481c] | 43 | |
---|
[c329f4d] | 44 | class SasViewApp(gui_manager.ViewApp): |
---|
[fa597990] | 45 | """ |
---|
| 46 | """ |
---|
| 47 | |
---|
| 48 | |
---|
[c329f4d] | 49 | class SasView(): |
---|
[fa597990] | 50 | """ |
---|
| 51 | """ |
---|
| 52 | def __init__(self): |
---|
| 53 | """ |
---|
| 54 | """ |
---|
| 55 | #from gui_manager import ViewApp |
---|
[c329f4d] | 56 | self.gui = SasViewApp(0) |
---|
[fa597990] | 57 | # Set the application manager for the GUI |
---|
| 58 | self.gui.set_manager(self) |
---|
| 59 | # Add perspectives to the basic application |
---|
| 60 | # Additional perspectives can still be loaded |
---|
| 61 | # dynamically |
---|
| 62 | # Note: py2exe can't find dynamically loaded |
---|
| 63 | # modules. We load the fitting module here |
---|
| 64 | # to ensure a complete Windows executable build. |
---|
[d4c19e5] | 65 | |
---|
[fa597990] | 66 | # Fitting perspective |
---|
[d4c19e5] | 67 | try: |
---|
| 68 | import sans.perspectives.fitting as module |
---|
| 69 | fitting_plug = module.Plugin() |
---|
| 70 | self.gui.add_perspective(fitting_plug) |
---|
[df7a7e3] | 71 | except Exception as inst: |
---|
| 72 | logging.error("Fitting problems: " + str(inst)) |
---|
[10b3e1e] | 73 | logging.error("%s: could not find Fitting plug-in module"% APP_NAME) |
---|
[d4c19e5] | 74 | logging.error(sys.exc_value) |
---|
| 75 | |
---|
[fa597990] | 76 | # P(r) perspective |
---|
| 77 | try: |
---|
| 78 | import sans.perspectives.pr as module |
---|
| 79 | pr_plug = module.Plugin(standalone=False) |
---|
| 80 | self.gui.add_perspective(pr_plug) |
---|
| 81 | except: |
---|
[10b3e1e] | 82 | logging.error("%s: could not find P(r) plug-in module"% APP_NAME) |
---|
[fa597990] | 83 | logging.error(sys.exc_value) |
---|
| 84 | |
---|
| 85 | #Invariant perspective |
---|
| 86 | try: |
---|
| 87 | import sans.perspectives.invariant as module |
---|
| 88 | invariant_plug = module.Plugin(standalone=False) |
---|
| 89 | self.gui.add_perspective(invariant_plug) |
---|
| 90 | except: |
---|
| 91 | raise |
---|
[10b3e1e] | 92 | logging.error("%s: could not find Invariant plug-in module"% \ |
---|
| 93 | APP_NAME) |
---|
[fa597990] | 94 | logging.error(sys.exc_value) |
---|
| 95 | |
---|
| 96 | #Calculator perspective |
---|
| 97 | try: |
---|
| 98 | import sans.perspectives.calculator as module |
---|
| 99 | calculator_plug = module.Plugin(standalone=False) |
---|
| 100 | self.gui.add_perspective(calculator_plug) |
---|
| 101 | except: |
---|
[10b3e1e] | 102 | logging.error("%s: could not find Calculator plug-in module"% \ |
---|
| 103 | APP_NAME) |
---|
[fa597990] | 104 | logging.error(sys.exc_value) |
---|
[334c50d] | 105 | |
---|
[d4c19e5] | 106 | |
---|
[fa597990] | 107 | # Add welcome page |
---|
| 108 | self.gui.set_welcome_panel(WelcomePanel) |
---|
| 109 | |
---|
| 110 | # Build the GUI |
---|
| 111 | self.gui.build_gui() |
---|
[19e614a] | 112 | # delete unused model folder |
---|
| 113 | self.gui.clean_plugin_models(PLUGIN_MODEL_DIR) |
---|
[fa597990] | 114 | # Start the main loop |
---|
| 115 | self.gui.MainLoop() |
---|
| 116 | |
---|
| 117 | |
---|
[930f559] | 118 | |
---|
[fa597990] | 119 | if __name__ == "__main__": |
---|
[5e491e6] | 120 | from multiprocessing import freeze_support |
---|
| 121 | freeze_support() |
---|
[c329f4d] | 122 | #Process(target=SasView).start() |
---|
| 123 | sasview = SasView() |
---|
[930f559] | 124 | |
---|
[df7a7e3] | 125 | |
---|