source: sasview/src/sas/sasview/welcome_panel.py @ 7879745

ESS_GUIESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalc
Last change on this file since 7879745 was b963b20, checked in by Paul Kienzle <pkienzle@…>, 7 years ago

pull config out of sas.sasgui so it can be used without reference to wx

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