1 | """ |
---|
2 | Welcome page |
---|
3 | """ |
---|
4 | import wx |
---|
5 | import wx.aui |
---|
6 | import wx.lib.hyperlink |
---|
7 | import os.path |
---|
8 | import os, sys |
---|
9 | import local_config as config |
---|
10 | from wx.lib.scrolledpanel import ScrolledPanel |
---|
11 | from sas.sasgui.guiframe.panel_base import PanelBase |
---|
12 | #Font size width |
---|
13 | if sys.platform.count("win32") > 0: |
---|
14 | FONT_VARIANT = 0 |
---|
15 | else: |
---|
16 | FONT_VARIANT = 1 |
---|
17 | |
---|
18 | class WelcomePanel(wx.aui.AuiNotebook, PanelBase): |
---|
19 | """ |
---|
20 | Panel created like about box as a welcome page |
---|
21 | Shows product name, current version, authors, |
---|
22 | 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 | kwds["style"] = wx.aui.AUI_NB_DEFAULT_STYLE |
---|
34 | |
---|
35 | wx.aui.AuiNotebook.__init__(self, parent, *args, **kwds) |
---|
36 | PanelBase.__init__(self) |
---|
37 | #For sasview the parent is guiframe |
---|
38 | self.parent = parent.parent |
---|
39 | self.frame = None |
---|
40 | self.manager = None |
---|
41 | |
---|
42 | welcome_page = WelcomePage(self) |
---|
43 | self.AddPage(welcome_page, "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 | Called when the welcome panel is closed |
---|
57 | """ |
---|
58 | if self.parent is not None: |
---|
59 | self.parent.on_close_welcome_panel() |
---|
60 | event.Veto() |
---|
61 | |
---|
62 | def set_data(self, data=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 | |
---|
80 | class WelcomePage(ScrolledPanel): |
---|
81 | """ |
---|
82 | Panel created like about box as a welcome page |
---|
83 | Shows product name, current version, authors, |
---|
84 | and link to the product page. |
---|
85 | """ |
---|
86 | ## Internal nickname for the window, used by the AUI manager |
---|
87 | window_name = "default" |
---|
88 | ## Name to appear on the window title bar |
---|
89 | window_caption = "Welcome panel" |
---|
90 | ## Flag to tell the AUI manager to put this panel in the center pane |
---|
91 | CENTER_PANE = True |
---|
92 | |
---|
93 | |
---|
94 | def __init__(self, parent, *args, **kwds): |
---|
95 | kwds["style"] = wx.DEFAULT_DIALOG_STYLE |
---|
96 | |
---|
97 | ScrolledPanel.__init__(self, parent, **kwds) |
---|
98 | self.SetupScrolling() |
---|
99 | image = os.path.join(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, |
---|
106 | config._acknowledgement) |
---|
107 | |
---|
108 | self.hyperlink_license = wx.StaticText(self, -1, |
---|
109 | "Comments? Bugs? Requests?") |
---|
110 | send_ticket = "Send us a ticket at: " |
---|
111 | send_ticket += "help@sasview.org" |
---|
112 | self.hyperlink_paper = \ |
---|
113 | wx.lib.hyperlink.HyperLinkCtrl(self, -1, |
---|
114 | send_ticket, URL=config._license) |
---|
115 | |
---|
116 | self.label_title = \ |
---|
117 | wx.StaticText(self, -1, |
---|
118 | config.__appname__ + " " + str(config.__version__)) |
---|
119 | try: |
---|
120 | build_num = str(config.__build__) |
---|
121 | except: |
---|
122 | build_num = str(config.__version__) |
---|
123 | self.label_build = wx.StaticText(self, -1, "Build: " + build_num) |
---|
124 | |
---|
125 | sizer_main = wx.BoxSizer(wx.VERTICAL) |
---|
126 | sizer_header = wx.BoxSizer(wx.HORIZONTAL) |
---|
127 | sizer_build = wx.BoxSizer(wx.VERTICAL) |
---|
128 | |
---|
129 | sizer_header.Add(self.bitmap_logo, 0, wx.EXPAND | wx.LEFT, 5) |
---|
130 | |
---|
131 | sizer_build.Add(self.label_acknowledgement, 0, |
---|
132 | wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) |
---|
133 | sizer_build.Add((5, 5)) |
---|
134 | sizer_build.Add(self.label_title, 0, |
---|
135 | wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) |
---|
136 | sizer_build.Add(self.label_build, 0, |
---|
137 | wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) |
---|
138 | sizer_build.Add(self.label_copyright, 0, |
---|
139 | wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) |
---|
140 | sizer_build.Add((5, 5)) |
---|
141 | sizer_build.Add(self.hyperlink_license, 0, |
---|
142 | wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) |
---|
143 | sizer_build.Add(self.hyperlink_paper, 0, |
---|
144 | wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) |
---|
145 | |
---|
146 | sizer_main.Add(sizer_header, 0, wx.TOP | wx.EXPAND, 3) |
---|
147 | sizer_main.Add(self.static_line_1, 0, wx.EXPAND, 0) |
---|
148 | sizer_main.Add(sizer_build, 0, wx.BOTTOM | wx.EXPAND, 3) |
---|
149 | |
---|
150 | self.SetAutoLayout(True) |
---|
151 | self.SetSizer(sizer_main) |
---|
152 | self.Fit() |
---|
153 | |
---|
154 | def set_data(self, data=None): |
---|
155 | """ |
---|
156 | """ |
---|
157 | pass |
---|
158 | |
---|
159 | class ViewApp(wx.App): |
---|
160 | """ |
---|
161 | Test application |
---|
162 | """ |
---|
163 | def OnInit(self): |
---|
164 | self.frame = WelcomeFrame(None, -1, "Test App") |
---|
165 | self.frame.Show(True) |
---|
166 | return True |
---|
167 | |
---|
168 | class WelcomeFrame(wx.Frame): |
---|
169 | """ |
---|
170 | Test frame |
---|
171 | """ |
---|
172 | def __init__(self, parent, id, title): |
---|
173 | wx.Frame.__init__(self, parent, id, title, size=(570, 400)) |
---|
174 | WelcomePanel(self) |
---|
175 | self.Centre() |
---|
176 | self.Show(True) |
---|
177 | |
---|
178 | if __name__ == "__main__": |
---|
179 | app = ViewApp(0) |
---|
180 | app.MainLoop() |
---|