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

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalcmagnetic_scattrelease-4.2.2ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since efe730d was efe730d, checked in by Paul Kienzle <pkienzle@…>, 8 years ago

move sasview to src/sas/sasview and refactor bundled apps for easier debugging

  • Property mode set to 100644
File size: 5.8 KB
RevLine 
[fa597990]1"""
[4851fe9e]2    Welcome page
[fa597990]3"""
4import wx
5import wx.aui
6import wx.lib.hyperlink
7import os.path
8import os, sys
[efe730d]9
[fa597990]10from wx.lib.scrolledpanel import ScrolledPanel
[efe730d]11
12from sas.sasgui import get_local_config
[d85c194]13from sas.sasgui.guiframe.panel_base import PanelBase
[efe730d]14config = get_local_config()
15
[7425bcf]16#Font size width
17if sys.platform.count("win32") > 0:
[fa597990]18    FONT_VARIANT = 0
19else:
[7425bcf]20    FONT_VARIANT = 1
21
[fa597990]22class WelcomePanel(wx.aui.AuiNotebook, PanelBase):
23    """
24        Panel created like about box  as a welcome page
[7425bcf]25        Shows product name, current version, authors,
26        and link to the product page.
[fa597990]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
[7425bcf]34
35
[2dda7ae1]36    def __init__(self, parent, *args, **kwds):
[fa597990]37        kwds["style"] = wx.aui.AUI_NB_DEFAULT_STYLE
[7425bcf]38
[fa597990]39        wx.aui.AuiNotebook.__init__(self, parent, *args, **kwds)
40        PanelBase.__init__(self)
[c329f4d]41        #For sasview the parent is guiframe
[ae84427]42        self.parent = parent.parent
43        self.frame = None
[7425bcf]44        self.manager = None
45
[fa597990]46        welcome_page = WelcomePage(self)
[b9f6d83]47        self.AddPage(welcome_page, "Welcome")
[7425bcf]48
[fa597990]49        self.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.on_close_page)
50        self.Center()
[7425bcf]51
[fa597990]52    def set_manager(self, manager):
53        """
54            the manager of the panel in this case the application itself
55        """
56        self.manager = manager
[7425bcf]57
[fa597990]58    def on_close_page(self, event):
59        """
[7425bcf]60            Called when the welcome panel is closed
[fa597990]61        """
62        if self.parent is not None:
63            self.parent.on_close_welcome_panel()
[7425bcf]64        event.Veto()
65
66    def set_data(self, data=None):
[fa597990]67        """
68        """
69        pass
[7425bcf]70
[ae84427]71    def set_frame(self, frame):
72        """
73        """
74        self.frame = frame
75        if frame != None:
76            self.frame.Bind(wx.EVT_CLOSE, self.on_close_page)
[7425bcf]77
[ae84427]78    def get_frame(self):
79        """
80        """
81        return self.frame
[7425bcf]82
83
[fa597990]84class WelcomePage(ScrolledPanel):
85    """
86        Panel created like about box  as a welcome page
[7425bcf]87        Shows product name, current version, authors,
88        and link to the product page.
[fa597990]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
[7425bcf]96
97
[fa597990]98    def __init__(self, parent, *args, **kwds):
99        kwds["style"] = wx.DEFAULT_DIALOG_STYLE
[7425bcf]100
[fa597990]101        ScrolledPanel.__init__(self, parent, **kwds)
102        self.SetupScrolling()
[7425bcf]103        image = os.path.join(config._welcome_image)
104        self.SetWindowVariant(variant=FONT_VARIANT)
[fa597990]105        self.bitmap_logo = wx.StaticBitmap(self, -1, wx.Bitmap(image))
[7425bcf]106
[fa597990]107        self.label_copyright = wx.StaticText(self, -1, config._copyright)
108        self.static_line_1 = wx.StaticLine(self, -1)
[7425bcf]109        self.label_acknowledgement = wx.StaticText(self, -1,
110                                                   config._acknowledgement)
111
112        self.hyperlink_license = wx.StaticText(self, -1,
[2dda7ae1]113                                               "Comments? Bugs? Requests?")
[0b96d74]114        send_ticket = "Send us a ticket at: "
[657e52c]115        send_ticket += "help@sasview.org"
[7425bcf]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__))
[3bc6090]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)
[7425bcf]128
[fa597990]129        sizer_main = wx.BoxSizer(wx.VERTICAL)
130        sizer_header = wx.BoxSizer(wx.HORIZONTAL)
131        sizer_build = wx.BoxSizer(wx.VERTICAL)
[7425bcf]132
133        sizer_header.Add(self.bitmap_logo, 0, wx.EXPAND | wx.LEFT, 5)
134
[2dda7ae1]135        sizer_build.Add(self.label_acknowledgement, 0,
[7425bcf]136                        wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
137        sizer_build.Add((5, 5))
[2dda7ae1]138        sizer_build.Add(self.label_title, 0,
[7425bcf]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)
[2dda7ae1]142        sizer_build.Add(self.label_copyright, 0,
[7425bcf]143                        wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
[2dda7ae1]144        sizer_build.Add((5, 5))
145        sizer_build.Add(self.hyperlink_license, 0,
[7425bcf]146                        wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
[2dda7ae1]147        sizer_build.Add(self.hyperlink_paper, 0,
[7425bcf]148                        wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
149
150        sizer_main.Add(sizer_header, 0, wx.TOP | wx.EXPAND, 3)
[fa597990]151        sizer_main.Add(self.static_line_1, 0, wx.EXPAND, 0)
[7425bcf]152        sizer_main.Add(sizer_build, 0, wx.BOTTOM | wx.EXPAND, 3)
153
[fa597990]154        self.SetAutoLayout(True)
155        self.SetSizer(sizer_main)
156        self.Fit()
[7425bcf]157
158    def set_data(self, data=None):
[fa597990]159        """
160        """
161        pass
162
163class ViewApp(wx.App):
[2dda7ae1]164    """
165        Test application
166    """
[fa597990]167    def OnInit(self):
[7425bcf]168        self.frame = WelcomeFrame(None, -1, "Test App")
[fa597990]169        self.frame.Show(True)
170        return True
171
172class WelcomeFrame(wx.Frame):
[2dda7ae1]173    """
174        Test frame
175    """
[fa597990]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)
[7425bcf]181
182if __name__ == "__main__":
[fa597990]183    app = ViewApp(0)
184    app.MainLoop()
Note: See TracBrowser for help on using the repository browser.