source: sasview/sansview/welcome_panel.py @ 9998be0

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 9998be0 was ae84427, checked in by Jae Cho <jhjcho@…>, 12 years ago

mdi frames for main applications

  • Property mode set to 100644
File size: 5.7 KB
Line 
1"""
2    Welcome page
3   
4"""
5import wx
6import wx.aui
7import wx.lib.hyperlink
8import os.path
9import os, sys
10import local_config as config
11from wx.lib.scrolledpanel import ScrolledPanel
12from sans.guiframe.panel_base import PanelBase
13#Font size width
14if sys.platform.count("win32")>0:
15    FONT_VARIANT = 0
16else:
17    FONT_VARIANT = 1 
18 
19class WelcomePanel(wx.aui.AuiNotebook, PanelBase):
20    """
21        Panel created like about box  as a welcome page
22        Shows product name, current version, authors, and link to the product page.
23    """
24    ## Internal nickname for the window, used by the AUI manager
25    window_name = "default"
26    ## Name to appear on the window title bar
27    window_caption = "Welcome panel"
28    ## Flag to tell the AUI manager to put this panel in the center pane
29    CENTER_PANE = True
30   
31   
32    def __init__(self, parent, *args, **kwds):
33       
34        kwds["style"] = wx.aui.AUI_NB_DEFAULT_STYLE
35       
36        wx.aui.AuiNotebook.__init__(self, parent, *args, **kwds)
37        PanelBase.__init__(self)
38        #For sasview the parent is guiframe
39        self.parent = parent.parent
40        self.frame = None
41       
42        welcome_page = WelcomePage(self)
43        self.AddPage(page=welcome_page, caption="Welcome")
44       
45        self.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.on_close_page)
46        self.Center()
47   
48    def set_manager(self, manager):
49        """
50            the manager of the panel in this case the application itself
51        """
52        self.manager = manager
53       
54    def on_close_page(self, event):
55        """
56           
57        """
58        if self.parent is not None:
59            self.parent.on_close_welcome_panel()
60        event.Veto() 
61       
62    def set_data(self, list=None):
63        """
64        """
65        pass
66   
67    def set_frame(self, frame):
68        """
69        """
70        self.frame = frame
71        if frame != None:
72            self.frame.Bind(wx.EVT_CLOSE, self.on_close_page)
73   
74    def get_frame(self):
75        """
76        """
77        return self.frame
78   
79   
80class WelcomePage(ScrolledPanel):
81    """
82        Panel created like about box  as a welcome page
83        Shows product name, current version, authors, and link to the product page.
84    """
85    ## Internal nickname for the window, used by the AUI manager
86    window_name = "default"
87    ## Name to appear on the window title bar
88    window_caption = "Welcome panel"
89    ## Flag to tell the AUI manager to put this panel in the center pane
90    CENTER_PANE = True
91   
92   
93    def __init__(self, parent, *args, **kwds):
94        import local_config
95        kwds["style"] = wx.DEFAULT_DIALOG_STYLE
96       
97        ScrolledPanel.__init__(self, parent, **kwds)
98        self.SetupScrolling()
99        image = os.path.join(local_config._welcome_image)
100        self.SetWindowVariant(variant = FONT_VARIANT)
101        self.bitmap_logo = wx.StaticBitmap(self, -1, wx.Bitmap(image))
102       
103        self.label_copyright = wx.StaticText(self, -1, config._copyright)
104        self.static_line_1 = wx.StaticLine(self, -1)
105        self.label_acknowledgement = wx.StaticText(self, -1, config._acknowledgement)
106       
107        self.hyperlink_license = wx.StaticText(self, -1, 
108                                               "Comments? Bugs? Requests?")
109        send_ticket = "Send us a ticket at: "
110        send_ticket += "help@sasview.org"
111        self.hyperlink_paper = wx.lib.hyperlink.HyperLinkCtrl(self, -1,
112            send_ticket, URL=config._license)
113       
114        self.label_title = wx.StaticText(self, -1, 
115            config.__appname__+ " "+str(config.__version__))
116        try:
117            build_num = str(config.__build__)
118        except:
119            build_num = str(config.__version__)
120        self.label_build = wx.StaticText(self, -1, "Build: " + build_num)
121     
122        sizer_main = wx.BoxSizer(wx.VERTICAL)
123        sizer_header = wx.BoxSizer(wx.HORIZONTAL)
124        sizer_build = wx.BoxSizer(wx.VERTICAL)
125       
126        sizer_header.Add(self.bitmap_logo, 0, wx.EXPAND|wx.LEFT, 5)
127       
128        sizer_build.Add(self.label_acknowledgement, 0,
129                        wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
130        sizer_build.Add((5,5))
131        sizer_build.Add(self.label_title, 0,
132                        wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
133        sizer_build.Add(self.label_build, 0, 
134                        wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
135        sizer_build.Add(self.label_copyright, 0,
136                        wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
137        sizer_build.Add((5, 5))
138        sizer_build.Add(self.hyperlink_license, 0,
139                        wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
140        sizer_build.Add(self.hyperlink_paper, 0,
141                        wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
142       
143        sizer_main.Add(sizer_header, 0, wx.TOP|wx.EXPAND, 3)
144        sizer_main.Add(self.static_line_1, 0, wx.EXPAND, 0)
145        sizer_main.Add(sizer_build,0 , wx.BOTTOM|wx.EXPAND, 3)
146       
147        self.SetAutoLayout(True)
148        self.SetSizer(sizer_main)
149        self.Fit()
150       
151    def set_data(self, list=None):
152        """
153        """
154        pass
155
156class ViewApp(wx.App):
157    """
158        Test application
159    """
160    def OnInit(self):
161        self.frame = WelcomeFrame(None, -1, "Test App")   
162        self.frame.Show(True)
163        return True
164
165class WelcomeFrame(wx.Frame):
166    """
167        Test frame
168    """
169    def __init__(self, parent, id, title):
170        wx.Frame.__init__(self, parent, id, title, size=(570, 400))
171        WelcomePanel(self)
172        self.Centre()
173        self.Show(True)
174   
175if __name__ == "__main__": 
176    app = ViewApp(0)
177    app.MainLoop()
Note: See TracBrowser for help on using the repository browser.