source: sasview/src/sas/sasview/welcome_panel.py @ 5251ec6

magnetic_scattrelease-4.2.2ticket-1009ticket-1249
Last change on this file since 5251ec6 was 5251ec6, checked in by Paul Kienzle <pkienzle@…>, 6 years ago

improved support for py37 in sasgui

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