[e2da832] | 1 | |
---|
[5062bbf] | 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 | ################################################################################ |
---|
[e2da832] | 11 | |
---|
[d89f09b] | 12 | import wx |
---|
| 13 | from sans.guiframe import gui_manager |
---|
[e2da832] | 14 | from welcome_panel import WelcomePanel |
---|
[d89f09b] | 15 | # For py2exe, import config here |
---|
| 16 | import local_config |
---|
[9f73a1d] | 17 | import logging |
---|
[d89f09b] | 18 | |
---|
[57acd41] | 19 | # Application dimensions |
---|
| 20 | APP_HEIGHT = 800 |
---|
| 21 | APP_WIDTH = 1000 |
---|
| 22 | |
---|
| 23 | class SansViewApp(gui_manager.ViewApp): |
---|
[5062bbf] | 24 | """ |
---|
| 25 | """ |
---|
[57acd41] | 26 | def OnInit(self): |
---|
[5062bbf] | 27 | """ |
---|
| 28 | """ |
---|
[2a1be2d9] | 29 | screen_size = wx.GetDisplaySize() |
---|
| 30 | app_height = APP_HEIGHT if screen_size[1]>APP_HEIGHT else screen_size[1]-50 |
---|
| 31 | app_width = APP_WIDTH if screen_size[0]>APP_WIDTH else screen_size[0]-50 |
---|
| 32 | |
---|
[57acd41] | 33 | self.frame = gui_manager.ViewerFrame(None, -1, local_config.__appname__, |
---|
[2a1be2d9] | 34 | window_height=app_height, window_width=app_width) |
---|
[57acd41] | 35 | self.frame.Show(True) |
---|
| 36 | |
---|
| 37 | if hasattr(self.frame, 'special'): |
---|
| 38 | self.frame.special.SetCurrent() |
---|
| 39 | self.SetTopWindow(self.frame) |
---|
| 40 | return True |
---|
[2d39535] | 41 | |
---|
[d89f09b] | 42 | class SansView(): |
---|
[5062bbf] | 43 | """ |
---|
| 44 | """ |
---|
[d89f09b] | 45 | def __init__(self): |
---|
| 46 | """ |
---|
| 47 | """ |
---|
| 48 | #from gui_manager import ViewApp |
---|
[57acd41] | 49 | self.gui = SansViewApp(0) |
---|
[9455d77] | 50 | # Set the application manager for the GUI |
---|
| 51 | self.gui.set_manager(self) |
---|
[d89f09b] | 52 | # Add perspectives to the basic application |
---|
| 53 | # Additional perspectives can still be loaded |
---|
| 54 | # dynamically |
---|
[365a17f6] | 55 | # Note: py2exe can't find dynamically loaded |
---|
| 56 | # modules. We load the fitting module here |
---|
| 57 | # to ensure a complete Windows executable build. |
---|
[4d6cce0] | 58 | |
---|
[1c8015f] | 59 | # P(r) perspective |
---|
| 60 | try: |
---|
| 61 | import sans.perspectives.pr as module |
---|
[4d6cce0] | 62 | pr_plug = module.Plugin(standalone=False) |
---|
| 63 | self.gui.add_perspective(pr_plug) |
---|
[1c8015f] | 64 | except: |
---|
| 65 | logging.error("SansView: could not find P(r) plug-in module") |
---|
[4d6cce0] | 66 | |
---|
| 67 | #Invariant perspective |
---|
| 68 | try: |
---|
| 69 | import sans.perspectives.invariant as module |
---|
| 70 | invariant_plug = module.Plugin(standalone=False) |
---|
| 71 | self.gui.add_perspective(invariant_plug) |
---|
| 72 | except: |
---|
| 73 | logging.error("SansView: could not find Invariant plug-in module") |
---|
| 74 | |
---|
[6e0e2d85] | 75 | #Calculator perspective |
---|
| 76 | try: |
---|
| 77 | import sans.perspectives.calculator as module |
---|
| 78 | calculator_plug = module.Plugin(standalone=False) |
---|
| 79 | self.gui.add_perspective(calculator_plug) |
---|
| 80 | except: |
---|
| 81 | logging.error("SansView: could not find Calculator plug-in module") |
---|
| 82 | |
---|
| 83 | # theory perspective |
---|
| 84 | try: |
---|
| 85 | import sans.perspectives.theory as module |
---|
| 86 | theory_plug = module.Plugin(standalone=False) |
---|
| 87 | self.gui.add_perspective(theory_plug) |
---|
| 88 | except: |
---|
[4ea3600] | 89 | logging.error("SansView: could not find theory plug-in module") |
---|
| 90 | |
---|
[ba69349] | 91 | # Fitting perspective |
---|
| 92 | import perspectives.fitting as module |
---|
| 93 | fitting_plug = module.Plugin() |
---|
| 94 | self.gui.add_perspective(fitting_plug) |
---|
[4d6cce0] | 95 | |
---|
[e2da832] | 96 | # Add welcome page |
---|
| 97 | self.gui.set_welcome_panel(WelcomePanel) |
---|
| 98 | |
---|
[d89f09b] | 99 | # Build the GUI |
---|
| 100 | self.gui.build_gui() |
---|
| 101 | |
---|
| 102 | # Start the main loop |
---|
| 103 | self.gui.MainLoop() |
---|
[c363d74] | 104 | |
---|
[d89f09b] | 105 | |
---|
| 106 | if __name__ == "__main__": |
---|
| 107 | sansview = SansView() |
---|