[fa597990] | 1 | """ |
---|
[4851fe9e] | 2 | Welcome page |
---|
[fa597990] | 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 |
---|
[d85c194] | 11 | from sas.sasgui.guiframe.panel_base import PanelBase |
---|
[7425bcf] | 12 | #Font size width |
---|
| 13 | if sys.platform.count("win32") > 0: |
---|
[fa597990] | 14 | FONT_VARIANT = 0 |
---|
| 15 | else: |
---|
[7425bcf] | 16 | FONT_VARIANT = 1 |
---|
| 17 | |
---|
[fa597990] | 18 | class WelcomePanel(wx.aui.AuiNotebook, PanelBase): |
---|
| 19 | """ |
---|
| 20 | Panel created like about box as a welcome page |
---|
[7425bcf] | 21 | Shows product name, current version, authors, |
---|
| 22 | and link to the product page. |
---|
[fa597990] | 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 |
---|
[7425bcf] | 30 | |
---|
| 31 | |
---|
[2dda7ae1] | 32 | def __init__(self, parent, *args, **kwds): |
---|
[fa597990] | 33 | kwds["style"] = wx.aui.AUI_NB_DEFAULT_STYLE |
---|
[7425bcf] | 34 | |
---|
[fa597990] | 35 | wx.aui.AuiNotebook.__init__(self, parent, *args, **kwds) |
---|
| 36 | PanelBase.__init__(self) |
---|
[c329f4d] | 37 | #For sasview the parent is guiframe |
---|
[ae84427] | 38 | self.parent = parent.parent |
---|
| 39 | self.frame = None |
---|
[7425bcf] | 40 | self.manager = None |
---|
| 41 | |
---|
[fa597990] | 42 | welcome_page = WelcomePage(self) |
---|
[b9f6d83] | 43 | self.AddPage(welcome_page, "Welcome") |
---|
[7425bcf] | 44 | |
---|
[fa597990] | 45 | self.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.on_close_page) |
---|
| 46 | self.Center() |
---|
[7425bcf] | 47 | |
---|
[fa597990] | 48 | def set_manager(self, manager): |
---|
| 49 | """ |
---|
| 50 | the manager of the panel in this case the application itself |
---|
| 51 | """ |
---|
| 52 | self.manager = manager |
---|
[7425bcf] | 53 | |
---|
[fa597990] | 54 | def on_close_page(self, event): |
---|
| 55 | """ |
---|
[7425bcf] | 56 | Called when the welcome panel is closed |
---|
[fa597990] | 57 | """ |
---|
| 58 | if self.parent is not None: |
---|
| 59 | self.parent.on_close_welcome_panel() |
---|
[7425bcf] | 60 | event.Veto() |
---|
| 61 | |
---|
| 62 | def set_data(self, data=None): |
---|
[fa597990] | 63 | """ |
---|
| 64 | """ |
---|
| 65 | pass |
---|
[7425bcf] | 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) |
---|
[7425bcf] | 73 | |
---|
[ae84427] | 74 | def get_frame(self): |
---|
| 75 | """ |
---|
| 76 | """ |
---|
| 77 | return self.frame |
---|
[7425bcf] | 78 | |
---|
| 79 | |
---|
[fa597990] | 80 | class WelcomePage(ScrolledPanel): |
---|
| 81 | """ |
---|
| 82 | Panel created like about box as a welcome page |
---|
[7425bcf] | 83 | Shows product name, current version, authors, |
---|
| 84 | and link to the product page. |
---|
[fa597990] | 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 |
---|
[7425bcf] | 92 | |
---|
| 93 | |
---|
[fa597990] | 94 | def __init__(self, parent, *args, **kwds): |
---|
| 95 | kwds["style"] = wx.DEFAULT_DIALOG_STYLE |
---|
[7425bcf] | 96 | |
---|
[fa597990] | 97 | ScrolledPanel.__init__(self, parent, **kwds) |
---|
| 98 | self.SetupScrolling() |
---|
[7425bcf] | 99 | image = os.path.join(config._welcome_image) |
---|
| 100 | self.SetWindowVariant(variant=FONT_VARIANT) |
---|
[fa597990] | 101 | self.bitmap_logo = wx.StaticBitmap(self, -1, wx.Bitmap(image)) |
---|
[7425bcf] | 102 | |
---|
[fa597990] | 103 | self.label_copyright = wx.StaticText(self, -1, config._copyright) |
---|
| 104 | self.static_line_1 = wx.StaticLine(self, -1) |
---|
[7425bcf] | 105 | self.label_acknowledgement = wx.StaticText(self, -1, |
---|
| 106 | config._acknowledgement) |
---|
| 107 | |
---|
| 108 | self.hyperlink_license = wx.StaticText(self, -1, |
---|
[2dda7ae1] | 109 | "Comments? Bugs? Requests?") |
---|
[0b96d74] | 110 | send_ticket = "Send us a ticket at: " |
---|
[657e52c] | 111 | send_ticket += "help@sasview.org" |
---|
[7425bcf] | 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__)) |
---|
[3bc6090] | 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) |
---|
[7425bcf] | 124 | |
---|
[fa597990] | 125 | sizer_main = wx.BoxSizer(wx.VERTICAL) |
---|
| 126 | sizer_header = wx.BoxSizer(wx.HORIZONTAL) |
---|
| 127 | sizer_build = wx.BoxSizer(wx.VERTICAL) |
---|
[7425bcf] | 128 | |
---|
| 129 | sizer_header.Add(self.bitmap_logo, 0, wx.EXPAND | wx.LEFT, 5) |
---|
| 130 | |
---|
[2dda7ae1] | 131 | sizer_build.Add(self.label_acknowledgement, 0, |
---|
[7425bcf] | 132 | wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) |
---|
| 133 | sizer_build.Add((5, 5)) |
---|
[2dda7ae1] | 134 | sizer_build.Add(self.label_title, 0, |
---|
[7425bcf] | 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) |
---|
[2dda7ae1] | 138 | sizer_build.Add(self.label_copyright, 0, |
---|
[7425bcf] | 139 | wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) |
---|
[2dda7ae1] | 140 | sizer_build.Add((5, 5)) |
---|
| 141 | sizer_build.Add(self.hyperlink_license, 0, |
---|
[7425bcf] | 142 | wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) |
---|
[2dda7ae1] | 143 | sizer_build.Add(self.hyperlink_paper, 0, |
---|
[7425bcf] | 144 | wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) |
---|
| 145 | |
---|
| 146 | sizer_main.Add(sizer_header, 0, wx.TOP | wx.EXPAND, 3) |
---|
[fa597990] | 147 | sizer_main.Add(self.static_line_1, 0, wx.EXPAND, 0) |
---|
[7425bcf] | 148 | sizer_main.Add(sizer_build, 0, wx.BOTTOM | wx.EXPAND, 3) |
---|
| 149 | |
---|
[fa597990] | 150 | self.SetAutoLayout(True) |
---|
| 151 | self.SetSizer(sizer_main) |
---|
| 152 | self.Fit() |
---|
[7425bcf] | 153 | |
---|
| 154 | def set_data(self, data=None): |
---|
[fa597990] | 155 | """ |
---|
| 156 | """ |
---|
| 157 | pass |
---|
| 158 | |
---|
| 159 | class ViewApp(wx.App): |
---|
[2dda7ae1] | 160 | """ |
---|
| 161 | Test application |
---|
| 162 | """ |
---|
[fa597990] | 163 | def OnInit(self): |
---|
[7425bcf] | 164 | self.frame = WelcomeFrame(None, -1, "Test App") |
---|
[fa597990] | 165 | self.frame.Show(True) |
---|
| 166 | return True |
---|
| 167 | |
---|
| 168 | class WelcomeFrame(wx.Frame): |
---|
[2dda7ae1] | 169 | """ |
---|
| 170 | Test frame |
---|
| 171 | """ |
---|
[fa597990] | 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) |
---|
[7425bcf] | 177 | |
---|
| 178 | if __name__ == "__main__": |
---|
[fa597990] | 179 | app = ViewApp(0) |
---|
| 180 | app.MainLoop() |
---|