1 | """ |
---|
2 | Welcome page |
---|
3 | |
---|
4 | """ |
---|
5 | import wx |
---|
6 | import wx.aui |
---|
7 | import wx.lib.hyperlink |
---|
8 | import os.path |
---|
9 | import os, sys |
---|
10 | import local_config as config |
---|
11 | from wx.lib.scrolledpanel import ScrolledPanel |
---|
12 | from sans.guiframe.panel_base import PanelBase |
---|
13 | #Font size width |
---|
14 | if sys.platform.count("win32")>0: |
---|
15 | FONT_VARIANT = 0 |
---|
16 | else: |
---|
17 | FONT_VARIANT = 1 |
---|
18 | |
---|
19 | class 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 | |
---|
32 | def __init__(self, parent, *args, **kwds): |
---|
33 | |
---|
34 | kwds["style"] = wx.aui.AUI_NB_DEFAULT_STYLE |
---|
35 | |
---|
36 | wx.aui.AuiNotebook.__init__(self, parent, *args, **kwds) |
---|
37 | PanelBase.__init__(self) |
---|
38 | #For sasview the parent is guiframe |
---|
39 | self.parent = parent |
---|
40 | |
---|
41 | welcome_page = WelcomePage(self) |
---|
42 | self.AddPage(page=welcome_page, caption="Welcome") |
---|
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 | |
---|
61 | def set_data(self, list=None): |
---|
62 | """ |
---|
63 | """ |
---|
64 | pass |
---|
65 | |
---|
66 | |
---|
67 | class WelcomePage(ScrolledPanel): |
---|
68 | """ |
---|
69 | Panel created like about box as a welcome page |
---|
70 | Shows product name, current version, authors, and link to the product page. |
---|
71 | """ |
---|
72 | ## Internal nickname for the window, used by the AUI manager |
---|
73 | window_name = "default" |
---|
74 | ## Name to appear on the window title bar |
---|
75 | window_caption = "Welcome panel" |
---|
76 | ## Flag to tell the AUI manager to put this panel in the center pane |
---|
77 | CENTER_PANE = True |
---|
78 | |
---|
79 | |
---|
80 | def __init__(self, parent, *args, **kwds): |
---|
81 | import local_config |
---|
82 | kwds["style"] = wx.DEFAULT_DIALOG_STYLE |
---|
83 | |
---|
84 | ScrolledPanel.__init__(self, parent, **kwds) |
---|
85 | self.SetupScrolling() |
---|
86 | image = os.path.join(local_config._welcome_image) |
---|
87 | self.SetWindowVariant(variant = FONT_VARIANT) |
---|
88 | self.bitmap_logo = wx.StaticBitmap(self, -1, wx.Bitmap(image)) |
---|
89 | |
---|
90 | self.label_copyright = wx.StaticText(self, -1, config._copyright) |
---|
91 | self.static_line_1 = wx.StaticLine(self, -1) |
---|
92 | self.label_acknowledgement = wx.StaticText(self, -1, config._acknowledgement) |
---|
93 | |
---|
94 | self.hyperlink_license = wx.StaticText(self, -1, |
---|
95 | "Comments? Bugs? Requests?") |
---|
96 | send_ticket = "Send us a ticket at: " |
---|
97 | send_ticket += "sansviewproject-developers@lists.sourceforge.net" |
---|
98 | self.hyperlink_paper = wx.lib.hyperlink.HyperLinkCtrl(self, -1, |
---|
99 | send_ticket, URL=config._license) |
---|
100 | |
---|
101 | self.label_title = wx.StaticText(self, -1, |
---|
102 | config.__appname__+ " "+str(config.__version__)) |
---|
103 | try: |
---|
104 | build_num = str(config.__build__) |
---|
105 | except: |
---|
106 | build_num = str(config.__version__) |
---|
107 | self.label_build = wx.StaticText(self, -1, "Build: " + build_num) |
---|
108 | |
---|
109 | sizer_main = wx.BoxSizer(wx.VERTICAL) |
---|
110 | sizer_header = wx.BoxSizer(wx.HORIZONTAL) |
---|
111 | sizer_build = wx.BoxSizer(wx.VERTICAL) |
---|
112 | |
---|
113 | sizer_header.Add(self.bitmap_logo, 0, wx.EXPAND|wx.LEFT, 5) |
---|
114 | |
---|
115 | sizer_build.Add(self.label_acknowledgement, 0, |
---|
116 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
117 | sizer_build.Add((5,5)) |
---|
118 | sizer_build.Add(self.label_title, 0, |
---|
119 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
120 | sizer_build.Add(self.label_build, 0, |
---|
121 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
122 | sizer_build.Add(self.label_copyright, 0, |
---|
123 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
124 | sizer_build.Add((5, 5)) |
---|
125 | sizer_build.Add(self.hyperlink_license, 0, |
---|
126 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
127 | sizer_build.Add(self.hyperlink_paper, 0, |
---|
128 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
129 | |
---|
130 | sizer_main.Add(sizer_header, 0, wx.TOP|wx.EXPAND, 3) |
---|
131 | sizer_main.Add(self.static_line_1, 0, wx.EXPAND, 0) |
---|
132 | sizer_main.Add(sizer_build,0 , wx.BOTTOM|wx.EXPAND, 3) |
---|
133 | |
---|
134 | self.SetAutoLayout(True) |
---|
135 | self.SetSizer(sizer_main) |
---|
136 | self.Fit() |
---|
137 | |
---|
138 | def set_data(self, list=None): |
---|
139 | """ |
---|
140 | """ |
---|
141 | pass |
---|
142 | |
---|
143 | class ViewApp(wx.App): |
---|
144 | """ |
---|
145 | Test application |
---|
146 | """ |
---|
147 | def OnInit(self): |
---|
148 | self.frame = WelcomeFrame(None, -1, "Test App") |
---|
149 | self.frame.Show(True) |
---|
150 | return True |
---|
151 | |
---|
152 | class WelcomeFrame(wx.Frame): |
---|
153 | """ |
---|
154 | Test frame |
---|
155 | """ |
---|
156 | def __init__(self, parent, id, title): |
---|
157 | wx.Frame.__init__(self, parent, id, title, size=(570, 400)) |
---|
158 | WelcomePanel(self) |
---|
159 | self.Centre() |
---|
160 | self.Show(True) |
---|
161 | |
---|
162 | if __name__ == "__main__": |
---|
163 | app = ViewApp(0) |
---|
164 | app.MainLoop() |
---|