source: sasview/guiframe/gui_manager.py @ 9a585d0

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 9a585d0 was 0bd2cd8, checked in by Gervaise Alina <gervyh@…>, 16 years ago

closing onf slicerpnale fixed

  • Property mode set to 100644
File size: 29.4 KB
Line 
1"""
2This software was developed by the University of Tennessee as part of the
3Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
4project funded by the US National Science Foundation.
5
6See the license text in license.txt
7
8copyright 2008, University of Tennessee
9
10How-to build an application using guiframe:
11
12 1- Write a main application script along the lines of dummyapp.py
13 2- Write a config script along the lines of config.py, and name it local_config.py
14 3- Write your plug-ins and place them in a directory called "perspectives".
15     - Look at local_perspectives/plotting for an example of a plug-in.
16     - A plug-in should define a class called Plugin. See abstract class below.
17
18"""
19import wx
20import wx.aui
21import os, sys
22try:
23    # Try to find a local config
24    import imp
25    path = os.getcwd()
26    if(os.path.isfile("%s/%s.py" % (path, 'local_config'))) or \
27      (os.path.isfile("%s/%s.pyc" % (path, 'local_config'))):
28            fObj, path, descr = imp.find_module('local_config', [path])
29            config = imp.load_module('local_config', fObj, path, descr) 
30    else:
31        # Try simply importing local_config
32        import local_config as config
33except:
34    # Didn't find local config, load the default
35    import config
36   
37from sans.guicomm.events import EVT_STATUS,Model2DPanelEvent
38from sans.guicomm.events import EVT_NEW_PLOT,EVT_SLICER_PARS_UPDATE
39import history
40import warnings
41warnings.simplefilter("ignore")
42
43import logging
44
45class Plugin:
46    """
47        This class defines the interface for a Plugin class
48        that can be used by the gui_manager.
49       
50        Plug-ins should be placed in a sub-directory called "perspectives".
51        For example, a plug-in called Foo should be place in "perspectives/Foo".
52        That directory contains at least two files:
53            perspectives/Foo/__init.py contains two lines:
54           
55                PLUGIN_ID = "Foo plug-in 1.0"
56                from Foo import *
57               
58            perspectives/Foo/Foo.py contains the definition of the Plugin
59            class for the Foo plug-in. The interface of that Plugin class
60            should follow the interface of the class you are looking at.
61    """
62   
63    def __init__(self):
64        """
65            Abstract class for gui_manager Plugins.
66        """
67        ## Plug-in name. It will appear on the application menu.
68        self.sub_menu = "Plugin"       
69       
70        ## Reference to the parent window. Filled by get_panels() below.
71        self.parent = None
72       
73        ## List of panels that you would like to open in AUI windows
74        #  for your plug-in. This defines your plug-in "perspective"
75        self.perspective = []
76       
77        raise RuntimeError, "gui_manager.Plugin is an abstract class"
78       
79    def populate_menu(self, id, parent):
80        """
81            Create and return the list of application menu
82            items for the plug-in.
83           
84            @param id: deprecated. Un-used.
85            @param parent: parent window
86            @return: plug-in menu
87        """
88        import wx
89        # Create a menu
90        plug_menu = wx.Menu()
91
92        # Always get event IDs from wx
93        id = wx.NewId()
94       
95        # Fill your menu
96        plug_menu.Append(id, '&Do something')
97        wx.EVT_MENU(owner, id, self._on_do_something)
98   
99        # Returns the menu and a name for it.
100        return [(id, plug_menu, "name of the application menu")]
101   
102   
103    def get_panels(self, parent):
104        """
105            Create and return the list of wx.Panels for your plug-in.
106            Define the plug-in perspective.
107           
108            Panels should inherit from DefaultPanel defined below,
109            or should present the same interface. They must define
110            "window_caption" and "window_name".
111           
112            @param parent: parent window
113            @return: list of panels
114        """
115        ## Save a reference to the parent
116        self.parent = parent
117       
118        # Define a panel
119        mypanel = DefaultPanel(self.parent, -1)
120       
121        # If needed, add its name to the perspective list
122        self.perspective.append(self.control_panel.window_name)
123
124        # Return the list of panels
125        return [mypanel]
126   
127    def get_context_menu(self, graph=None):
128        """
129            This method is optional.
130       
131            When the context menu of a plot is rendered, the
132            get_context_menu method will be called to give you a
133            chance to add a menu item to the context menu.
134           
135            A ref to a Graph object is passed so that you can
136            investigate the plot content and decide whether you
137            need to add items to the context menu. 
138           
139            This method returns a list of menu items.
140            Each item is itself a list defining the text to
141            appear in the menu, a tool-tip help text, and a
142            call-back method.
143           
144            @param graph: the Graph object to which we attach the context menu
145            @return: a list of menu items with call-back function
146        """
147        return [["Menu text", 
148                 "Tool-tip help text", 
149                 self._on_context_do_something]]     
150   
151    def get_perspective(self):
152        """
153            Get the list of panel names for this perspective
154        """
155        return self.perspective
156   
157    def on_perspective(self, event):
158        """
159            Call back function for the perspective menu item.
160            We notify the parent window that the perspective
161            has changed.
162            @param event: menu event
163        """
164        self.parent.set_perspective(self.perspective)
165   
166    def post_init(self):
167        """
168            Post initialization call back to close the loose ends
169        """
170        pass
171
172
173class ViewerFrame(wx.Frame):
174    """
175        Main application frame
176    """
177    def __init__(self, parent, id, title, window_height=700, window_width=900):
178    #def __init__(self, parent, id, title, window_height=800, window_width=800):
179        """
180            Initialize the Frame object
181        """
182        from local_perspectives.plotting import plotting
183        #wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, size=(800, 700))
184        wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, size=(900, 600))
185       
186        # Preferred window size
187        self._window_height = window_height
188        self._window_width  = window_width
189       
190        # Logging info
191        logging.basicConfig(level=logging.DEBUG,
192                    format='%(asctime)s %(levelname)s %(message)s',
193                    filename='sans_app.log',
194                    filemode='w')       
195       
196        path = os.path.dirname(__file__)
197        ico_file = os.path.join(path,'images/ball.ico')
198        if os.path.isfile(ico_file):
199            self.SetIcon(wx.Icon(ico_file, wx.BITMAP_TYPE_ICO))
200        else:
201            ico_file = os.path.join(os.getcwd(),'images/ball.ico')
202            if os.path.isfile(ico_file):
203                self.SetIcon(wx.Icon(ico_file, wx.BITMAP_TYPE_ICO))
204       
205        ## Application manager
206        self.app_manager = None
207       
208        ## Find plug-ins
209        # Modify this so that we can specify the directory to look into
210        self.plugins = self._find_plugins()
211        self.plugins.append(plotting.Plugin())
212
213        ## List of panels
214        self.panels = {}
215
216        ## Next available ID for wx gui events
217        #TODO:  No longer used - remove all calls to this
218        self.next_id = 20000
219
220        # Default locations
221        self._default_save_location = os.getcwd()       
222
223        ## Default welcome panel
224        self.defaultPanel    = DefaultPanel(self, -1, style=wx.RAISED_BORDER)
225       
226        # History panel
227        self.histPanel     = history.HistoryPanel(self, style=wx.RAISED_BORDER)
228        # self.build_gui()
229       
230        # Register the close event so it calls our own method
231        wx.EVT_CLOSE(self, self._onClose)
232        # Register to status events
233        self.Bind(EVT_STATUS, self._on_status_event)
234        self.Bind(EVT_SLICER_PARS_UPDATE, self._onEVT_SLICER_PANEL)
235       
236       
237    def _onEVT_SLICER_PANEL(self, event):
238        """
239            receive and event telling to update a panel with a name starting with
240            event.panel_name. this method update slicer panel for a given interactor.
241            @param event: contains type of slicer , paramaters for updating the panel
242            and panel_name to find the slicer 's panel concerned.
243        """
244        for item in self.panels:
245            if self.panels[item].window_caption.startswith(event.panel_name): 
246                self.panels[item].set_slicer(event.type, event.params)
247                self._mgr.Update()
248                break
249       
250    def build_gui(self):
251        # Set up the layout
252        self._setup_layout()
253       
254        # Set up the menu
255        self._setup_menus()
256       
257        self.Fit()
258       
259        #self._check_update(None)
260             
261    def _setup_layout(self):
262        """
263            Set up the layout
264        """
265        # Status bar
266        self.sb = self.CreateStatusBar()
267        self.SetStatusText("")
268
269        # Add panel
270        self._mgr = wx.aui.AuiManager(self)
271       
272        # Load panels
273        self._load_panels()
274       
275        self._mgr.Update()
276
277    def add_perspective(self, plugin):
278        """
279            Add a perspective if it doesn't already
280            exist.
281        """
282        is_loaded = False
283        for item in self.plugins:
284             if plugin.__class__==item.__class__:
285                 print "Plugin %s already loaded" % plugin.__class__.__name__
286                 is_loaded = True
287                 
288        if not is_loaded:
289            self.plugins.append(plugin)
290     
291    def _find_plugins(self, dir="perspectives"):
292        """
293            Find available perspective plug-ins
294            @param dir: directory in which to look for plug-ins
295            @return: list of plug-ins
296        """
297        import imp
298        print "Looking for plug-ins in %s" % dir
299        # List of plug-in objects
300       
301        #path_exe = os.getcwd()
302        #path_plugs = os.path.join(path_exe, dir)
303        f = open("load.log",'w') 
304        f.write(os.getcwd()+'\n\n')
305        #f.write(str(os.listdir(dir))+'\n')
306       
307       
308        plugins = []
309        # Go through files in panels directory
310        try:
311            list = os.listdir(dir)
312            for item in list:
313                toks = os.path.splitext(os.path.basename(item))
314                name = None
315                if not toks[0] == '__init__':
316                   
317                    if toks[1]=='.py' or toks[1]=='':
318                        name = toks[0]
319               
320                    path = [os.path.abspath(dir)]
321                    file = None
322                    try:
323                        if toks[1]=='':
324                            f.write("trying to import \n")
325                            mod_path = '.'.join([dir, name])
326                            f.write("mod_path= %s\n" % mod_path)
327                            module = __import__(mod_path, globals(), locals(), [name])
328                            f.write(str(module)+'\n')
329                        else:
330                            (file, path, info) = imp.find_module(name, path)
331                            module = imp.load_module( name, file, item, info )
332                        if hasattr(module, "PLUGIN_ID"):
333                            try:
334                                plugins.append(module.Plugin())
335                                print "Found plug-in: %s" % module.PLUGIN_ID
336                            except:
337                                config.printEVT("Error accessing PluginPanel in %s\n  %s" % (name, sys.exc_value))
338                       
339                    except:
340                        print sys.exc_value
341                        f.write(str(sys.exc_value)+'\n')
342                    finally:
343                        if not file==None:
344                            file.close()
345        except:
346            # Should raise and catch at a higher level and display error on status bar
347            pass   
348        f.write(str(plugins)+'\n')
349        f.close()
350        return plugins
351   
352       
353     
354    def _load_panels(self):
355        """
356            Load all panels in the panels directory
357        """
358       
359        # Look for plug-in panels
360        panels = []       
361        for item in self.plugins:
362            if hasattr(item, "get_panels"):
363                ps = item.get_panels(self)
364                panels.extend(ps)
365
366        # Show a default panel with some help information
367        # It also sets the size of the application windows
368        self.panels["default"] = self.defaultPanel
369         # History panel
370        self.panels["historyPanel"] = self.histPanel 
371       
372        self._mgr.AddPane(self.defaultPanel, wx.aui.AuiPaneInfo().
373                              Name("default").
374                              CenterPane().
375                              # This is where we set the size of the application window
376                              BestSize(wx.Size(self._window_width, self._window_height)).
377                              MinSize(wx.Size(self._window_width, self._window_height)).
378                              Show())
379        self._mgr.AddPane(self.histPanel, wx.aui.AuiPaneInfo().
380                          Name("historyPanel").Caption("History").
381                          #Float().
382                          Bottom().
383                          Dock().
384                          TopDockable().
385                          BottomDockable().
386                          LeftDockable().
387                          RightDockable().
388                          MinimizeButton().
389                          Hide().
390                          #Show().
391                          BestSize(wx.Size(500,600)).
392                          MinSize(wx.Size(200,150)))
393
394        # Add the panels to the AUI manager
395        for panel_class in panels:
396            p = panel_class
397            id = wx.NewId()
398           
399            # Check whether we need to put this panel
400            # in the center pane
401            if hasattr(p, "CENTER_PANE"):
402                if p.CENTER_PANE:
403                    self.panels[str(id)] = p
404                    self._mgr.AddPane(p, wx.aui.AuiPaneInfo().
405                                          Name(p.window_name).Caption(p.window_caption).
406                                          CenterPane().
407                                          BestSize(wx.Size(600,600)).
408                                          MinSize(wx.Size(400,400)).
409                                          #BestSize(wx.Size(500,500)).
410                                          #MinSize(wx.Size(200,200)).
411                                          Hide())
412               
413            else:
414                self.panels[str(id)] = p
415                self._mgr.AddPane(p, wx.aui.AuiPaneInfo().
416                                  Name(p.window_name).Caption(p.window_caption).
417                                  #Floatable().
418                                  #Float().
419                                  Right().
420                                  Dock().
421                                  TopDockable().
422                                  BottomDockable().
423                                  LeftDockable().
424                                  RightDockable().
425                                  MinimizeButton().
426                                  Hide().
427                                  #Show().
428                                  BestSize(wx.Size(600,600)).
429                                  MinSize(wx.Size(500,500)))
430                                  #BestSize(wx.Size(400,400)).
431                                  #MinSize(wx.Size(300,300)))
432
433               
434       
435    def get_context_menu(self, graph=None):
436        """
437            Get the context menu items made available
438            by the different plug-ins.
439            This function is used by the plotting module
440        """
441        menu_list = []
442        for item in self.plugins:
443            if hasattr(item, "get_context_menu"):
444                menu_list.extend(item.get_context_menu(graph))
445           
446        return menu_list
447       
448    def popup_panel(self, p):
449        """
450            Add a panel object to the AUI manager
451            @param p: panel object to add to the AUI manager
452            @return: ID of the event associated with the new panel [int]
453        """
454       
455        ID = wx.NewId()
456        self.panels[str(ID)] = p
457       
458        count = 0
459        for item in self.panels:
460            if self.panels[item].window_name.startswith(p.window_name): 
461                count += 1
462       
463        windowname = p.window_name
464        caption = p.window_caption
465       
466        if count>0:
467            windowname += str(count+1)
468            caption += (' '+str(count))
469         
470        p.window_name = windowname
471        p.window_caption = caption
472           
473        self._mgr.AddPane(p, wx.aui.AuiPaneInfo().
474                          Name(windowname).Caption(caption).
475                          Floatable().
476                          #Float().
477                          Right().
478                          Dock().
479                          TopDockable().
480                          BottomDockable().
481                          LeftDockable().
482                          RightDockable().
483                          MinimizeButton().
484                          #Hide().
485                          #Show().
486                          BestSize(wx.Size(600,600)).
487                          MinSize(wx.Size(500,500)))
488                          #BestSize(wx.Size(400,400)).
489                          #MinSize(wx.Size(350,350)))
490        pane = self._mgr.GetPane(windowname)
491        self._mgr.MaximizePane(pane)
492        self._mgr.RestoreMaximizedPane()
493       
494       
495        # Register for showing/hiding the panel
496       
497        wx.EVT_MENU(self, ID, self._on_view)
498       
499        self._mgr.Update()
500        return ID
501       
502    def _setup_menus(self):
503        """
504            Set up the application menus
505        """
506        # Menu
507        menubar = wx.MenuBar()
508       
509        # File menu
510        filemenu = wx.Menu()
511       
512        id = wx.NewId()
513        filemenu.Append(id, '&Open', 'Open a file')
514        wx.EVT_MENU(self, id, self._on_open)
515       
516        #id = wx.NewId()
517        #filemenu.Append(id, '&History', 'Register previous States')
518        #wx.EVT_MENU(self, id, self._onHistoryPanel)
519       
520        id = wx.NewId()
521        filemenu.Append(id,'&Quit', 'Exit') 
522        wx.EVT_MENU(self, id, self.Close)
523       
524        # Add sub menus
525        menubar.Append(filemenu,  '&File')
526       
527        # Plot menu
528        # Attach a menu item for each panel in our
529        # panel list that also appears in a plug-in.
530        # TODO: clean this up. We should just identify
531        # plug-in panels and add them all.
532       
533        # Only add the panel menu if there is more than one panel
534        n_panels = 0
535        for plug in self.plugins:
536            pers = plug.get_perspective()
537            if len(pers)>0:
538                n_panels += 1
539       
540        if n_panels>1:
541            viewmenu = wx.Menu()
542            for plug in self.plugins:
543                plugmenu = wx.Menu()
544                pers = plug.get_perspective()
545                if len(pers)>0:
546                    for item in self.panels:
547                        if item == 'default':
548                            continue
549                        panel = self.panels[item]
550                        if panel.window_name in pers:
551                            plugmenu.Append(int(item), panel.window_caption, "Show %s window" % panel.window_caption)
552                           
553                           
554                           
555                            wx.EVT_MENU(self, int(item), self._on_view)
556                   
557                    viewmenu.AppendMenu(wx.NewId(), plug.sub_menu, plugmenu, plug.sub_menu)
558               
559            menubar.Append(viewmenu, '&Panel')
560
561        # Perspective
562        # Attach a menu item for each defined perspective.
563        # Only add the perspective menu if there are more than one perspectves
564        n_perspectives = 0
565        for plug in self.plugins:
566            if len(plug.get_perspective()) > 0:
567                n_perspectives += 1
568       
569        if n_perspectives>1:
570            p_menu = wx.Menu()
571            for plug in self.plugins:
572                if len(plug.get_perspective()) > 0:
573                    id = wx.NewId()
574                    p_menu.Append(id, plug.sub_menu, "Switch to %s perspective" % plug.sub_menu)
575                    wx.EVT_MENU(self, id, plug.on_perspective)
576            menubar.Append(p_menu,   '&Perspective')
577 
578        # Help menu
579        helpmenu = wx.Menu()
580
581        # Look for help item in plug-ins
582        for item in self.plugins:
583            if hasattr(item, "help"):
584                id = wx.NewId()
585                helpmenu.Append(id,'&%s help' % item.sub_menu, '')
586                wx.EVT_MENU(self, id, item.help)
587       
588        if config._do_aboutbox:
589            id = wx.NewId()
590            helpmenu.Append(id,'&About', 'Software information')
591            wx.EVT_MENU(self, id, self._onAbout)
592        id = wx.NewId()
593        helpmenu.Append(id,'&Check for update', 'Check for the latest version of %s' % config.__appname__)
594        wx.EVT_MENU(self, id, self._check_update)
595       
596       
597       
598       
599        # Look for plug-in menus
600        # Add available plug-in sub-menus.
601        for item in self.plugins:
602            if hasattr(item, "populate_menu"):
603                for (self.next_id, menu, name) in item.populate_menu(self.next_id, self):
604                    menubar.Append(menu, name)
605                   
606
607        menubar.Append(helpmenu, '&Help')
608         
609        self.SetMenuBar(menubar)
610       
611       
612       
613    def _on_status_event(self, evt):
614        """
615            Display status message
616        """
617        self.SetStatusText(str(evt.status))
618
619       
620    def _on_view(self, evt):
621        """
622            A panel was selected to be shown. If it's not already
623            shown, display it.
624            @param evt: menu event
625        """
626        self.show_panel(evt.GetId())
627
628    def show_panel(self, uid):
629        """
630            Shows the panel with the given id
631            @param uid: unique ID number of the panel to show
632        """
633        ID = str(uid)
634        config.printEVT("show_panel: %s" % ID)
635        if ID in self.panels.keys():
636            if not self._mgr.GetPane(self.panels[ID].window_name).IsShown():
637                self._mgr.GetPane(self.panels[ID].window_name).Show()
638                # Hide default panel
639                self._mgr.GetPane(self.panels["default"].window_name).Hide()
640               
641               
642            self._mgr.Update()
643    def _onHistoryPanel(self, event):
644        print "on history"
645        if not self._mgr.GetPane("historyPanel").IsShown():
646            self._mgr.GetPane("historyPanel").Show()
647        self._mgr.Update()
648        return
649       
650    def _on_open(self, event):
651   
652        from data_loader import plot_data
653        path = self.choose_file()
654           
655        if path and os.path.isfile(path):
656            plot_data(self, path)
657           
658       
659       
660    def _onClose(self, event):
661        import sys
662        wx.Exit()
663        sys.exit()
664                   
665    def Close(self, event=None):
666        """
667            Quit the application
668        """
669        import sys
670        wx.Frame.Close(self)
671        wx.Exit()
672        sys.exit()
673
674 
675    def _check_update(self, event=None): 
676        """
677            Check with the deployment server whether a new version
678            of the application is available
679        """
680        import urllib
681        try: 
682            h = urllib.urlopen(config.__update_URL__)
683            lines = h.readlines()
684            line = ''
685            if len(lines)>0:
686                line = lines[0]
687               
688                toks = line.lstrip().rstrip().split('.')
689                toks_current = config.__version__.split('.')
690                update_available = False
691                for i in range(len(toks)):
692                    if len(toks[i].strip())>0:
693                        if int(toks[i].strip())>int(toks_current[i]):
694                            update_available = True
695                if update_available:
696                    #print "Version %s is available" % line.rstrip().lstrip()
697                    self.SetStatusText("Version %s is available! See the Help menu to download it." % line.rstrip().lstrip())
698                    if event != None:
699                        import webbrowser
700                        webbrowser.open(config.__download_page__)
701                else:
702                    if event != None:
703                        self.SetStatusText("You have the latest version of %s" % config.__appname__)
704        except:
705            if event != None:
706                self.SetStatusText("You have the latest version of %s" % config.__appname__)
707           
708           
709    def _onAbout(self, evt):
710        """
711            Pop up the about dialog
712            @param evt: menu event
713        """
714        if config._do_aboutbox:
715            import aboutbox 
716            dialog = aboutbox.DialogAbout(None, -1, "")
717            dialog.ShowModal()
718           
719    def set_manager(self, manager):
720        """
721            Sets the application manager for this frame
722            @param manager: frame manager
723        """
724        self.app_manager = manager
725       
726    def post_init(self):
727        """
728            This initialization method is called after the GUI
729            has been created and all plug-ins loaded. It calls
730            the post_init() method of each plug-in (if it exists)
731            so that final initialization can be done.
732        """
733        for item in self.plugins:
734            if hasattr(item, "post_init"):
735                item.post_init()
736       
737    def set_perspective(self, panels):
738        """
739            Sets the perspective of the GUI.
740            Opens all the panels in the list, and closes
741            all the others.
742           
743            @param panels: list of panels
744        """
745        for item in self.panels:
746            # Check whether this is a sticky panel
747            if hasattr(self.panels[item], "ALWAYS_ON"):
748                if self.panels[item].ALWAYS_ON:
749                    continue 
750           
751            if self.panels[item].window_name in panels:
752                if not self._mgr.GetPane(self.panels[item].window_name).IsShown():
753                    self._mgr.GetPane(self.panels[item].window_name).Show()
754            else:
755                if self._mgr.GetPane(self.panels[item].window_name).IsShown():
756                    self._mgr.GetPane(self.panels[item].window_name).Hide()
757                 
758        self._mgr.Update()
759       
760    def choose_file(self):
761        """
762            Functionality that belongs elsewhere
763            Should add a hook to specify the preferred file type/extension.
764        """
765        #TODO: clean this up
766        from data_loader import choose_data_file
767        path = choose_data_file(self, self._default_save_location)
768        if not path==None:
769            try:
770                self._default_save_location = os.path.dirname(path)
771            except:
772                pass
773        return path
774   
775    def load_ascii_1D(self, path):
776        from data_loader import load_ascii_1D
777        return load_ascii_1D(path)
778                 
779class DefaultPanel(wx.Panel):
780    """
781        Defines the API for a panels to work with
782        the GUI manager
783    """
784    ## Internal nickname for the window, used by the AUI manager
785    window_name = "default"
786    ## Name to appear on the window title bar
787    window_caption = "Welcome panel"
788    ## Flag to tell the AUI manager to put this panel in the center pane
789    CENTER_PANE = True
790
791 
792# Toy application to test this Frame
793class ViewApp(wx.App):
794    def OnInit(self):
795        #from gui_manager import ViewerFrame
796        self.frame = ViewerFrame(None, -1, config.__appname__)   
797        self.frame.Show(True)
798
799        if hasattr(self.frame, 'special'):
800            print "Special?", self.frame.special.__class__.__name__
801            self.frame.special.SetCurrent()
802        self.SetTopWindow(self.frame)
803        return True
804   
805    def set_manager(self, manager):
806        """
807            Sets a reference to the application manager
808            of the GUI manager (Frame)
809        """
810        self.frame.set_manager(manager)
811       
812    def build_gui(self):
813        """
814            Build the GUI
815        """
816        self.frame.build_gui()
817        self.frame.post_init()
818       
819    def add_perspective(self, perspective):
820        """
821            Manually add a perspective to the application GUI
822        """
823        self.frame.add_perspective(perspective)
824       
825
826if __name__ == "__main__": 
827    app = ViewApp(0)
828    app.MainLoop()             
Note: See TracBrowser for help on using the repository browser.