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 | ################################################################################ |
---|
11 | |
---|
12 | import wx |
---|
13 | import os |
---|
14 | import sys |
---|
15 | # The below will make sure that sansview application uses the matplotlib font |
---|
16 | # bundled with sansview. |
---|
17 | if hasattr(sys, 'frozen'): |
---|
18 | mplconfigdir = os.path.join(sys.prefix, '.matplotlib') |
---|
19 | if not os.path.exists(mplconfigdir): |
---|
20 | os.mkdir(mplconfigdir) |
---|
21 | os.environ['MPLCONFIGDIR'] = mplconfigdir |
---|
22 | |
---|
23 | from sans.guiframe import gui_manager |
---|
24 | from sans.guiframe.gui_style import GUIFRAME |
---|
25 | from welcome_panel import WelcomePanel |
---|
26 | # For py2exe, import config here |
---|
27 | import local_config |
---|
28 | import logging |
---|
29 | |
---|
30 | # Application dimensions |
---|
31 | APP_HEIGHT = 800 |
---|
32 | APP_WIDTH = 1000 |
---|
33 | GSTYLE = GUIFRAME.MULTIPLE_APPLICATIONS |
---|
34 | class SansViewApp(gui_manager.ViewApp): |
---|
35 | """ |
---|
36 | """ |
---|
37 | def OnInit(self): |
---|
38 | """ |
---|
39 | """ |
---|
40 | screen_size = wx.GetDisplaySize() |
---|
41 | app_height = APP_HEIGHT if screen_size[1]>APP_HEIGHT else screen_size[1]-50 |
---|
42 | app_width = APP_WIDTH if screen_size[0]>APP_WIDTH else screen_size[0]-50 |
---|
43 | |
---|
44 | self.frame = gui_manager.ViewerFrame(None, -1, |
---|
45 | local_config.__appname__, |
---|
46 | gui_style=GSTYLE, |
---|
47 | window_height=app_height, |
---|
48 | window_width=app_width) |
---|
49 | self.frame.Show(True) |
---|
50 | |
---|
51 | if hasattr(self.frame, 'special'): |
---|
52 | self.frame.special.SetCurrent() |
---|
53 | self.SetTopWindow(self.frame) |
---|
54 | return True |
---|
55 | |
---|
56 | class SansView(): |
---|
57 | """ |
---|
58 | """ |
---|
59 | def __init__(self): |
---|
60 | """ |
---|
61 | """ |
---|
62 | #from gui_manager import ViewApp |
---|
63 | self.gui = SansViewApp(0) |
---|
64 | # Set the application manager for the GUI |
---|
65 | self.gui.set_manager(self) |
---|
66 | # Add perspectives to the basic application |
---|
67 | # Additional perspectives can still be loaded |
---|
68 | # dynamically |
---|
69 | # Note: py2exe can't find dynamically loaded |
---|
70 | # modules. We load the fitting module here |
---|
71 | # to ensure a complete Windows executable build. |
---|
72 | |
---|
73 | # P(r) perspective |
---|
74 | try: |
---|
75 | import sans.perspectives.pr as module |
---|
76 | pr_plug = module.Plugin(standalone=False) |
---|
77 | self.gui.add_perspective(pr_plug) |
---|
78 | except: |
---|
79 | logging.error("SansView: could not find P(r) plug-in module") |
---|
80 | logging.error(sys.exc_value) |
---|
81 | |
---|
82 | #Invariant perspective |
---|
83 | try: |
---|
84 | import sans.perspectives.invariant as module |
---|
85 | invariant_plug = module.Plugin(standalone=False) |
---|
86 | self.gui.add_perspective(invariant_plug) |
---|
87 | except: |
---|
88 | logging.error("SansView: could not find Invariant plug-in module") |
---|
89 | logging.error(sys.exc_value) |
---|
90 | |
---|
91 | #Calculator perspective |
---|
92 | try: |
---|
93 | import sans.perspectives.calculator as module |
---|
94 | calculator_plug = module.Plugin(standalone=False) |
---|
95 | self.gui.add_perspective(calculator_plug) |
---|
96 | except: |
---|
97 | logging.error("SansView: could not find Calculator plug-in module") |
---|
98 | logging.error(sys.exc_value) |
---|
99 | |
---|
100 | # theory perspective |
---|
101 | try: |
---|
102 | import sans.perspectives.theory as module |
---|
103 | theory_plug = module.Plugin(standalone=False) |
---|
104 | self.gui.add_perspective(theory_plug) |
---|
105 | except: |
---|
106 | logging.error("SansView: could not find theory plug-in module") |
---|
107 | logging.error(sys.exc_value) |
---|
108 | |
---|
109 | # Fitting perspective |
---|
110 | import perspectives.fitting as module |
---|
111 | fitting_plug = module.Plugin() |
---|
112 | self.gui.add_perspective(fitting_plug) |
---|
113 | |
---|
114 | # Add welcome page |
---|
115 | self.gui.set_welcome_panel(WelcomePanel) |
---|
116 | |
---|
117 | # Build the GUI |
---|
118 | self.gui.build_gui() |
---|
119 | |
---|
120 | # Start the main loop |
---|
121 | self.gui.MainLoop() |
---|
122 | |
---|
123 | |
---|
124 | if __name__ == "__main__": |
---|
125 | sansview = SansView() |
---|