source: sasview/sansview/welcome_panel.py @ afb5080

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 afb5080 was b9f6d83, checked in by Mathieu Doucet <doucetm@…>, 11 years ago

Re #216 Merging wx30 branch

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