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