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