[e2da832] | 1 | """ |
---|
| 2 | Welcome panel for SansView |
---|
| 3 | """ |
---|
| 4 | """ |
---|
| 5 | This software was developed by the University of Tennessee as part of the |
---|
| 6 | Distributed Data Analysis of Neutron Scattering Experiments (DANSE) |
---|
| 7 | project funded by the US National Science Foundation. |
---|
| 8 | |
---|
| 9 | See the license text in license.txt |
---|
| 10 | |
---|
| 11 | copyright 2009, University of Tennessee |
---|
| 12 | """ |
---|
| 13 | |
---|
| 14 | import wx |
---|
[9455d77] | 15 | import wx.aui |
---|
[e2da832] | 16 | import wx.lib.hyperlink |
---|
| 17 | import os.path |
---|
[f1aa385] | 18 | import os, sys |
---|
[e2da832] | 19 | import local_config as config |
---|
| 20 | |
---|
[f1aa385] | 21 | #Font size width |
---|
| 22 | if sys.platform.count("win32")>0: |
---|
| 23 | FONT_VARIANT = 0 |
---|
| 24 | else: |
---|
| 25 | FONT_VARIANT = 1 |
---|
[9455d77] | 26 | |
---|
| 27 | class WelcomePanel(wx.aui.AuiNotebook): |
---|
| 28 | """ |
---|
| 29 | Panel created like about box as a welcome page |
---|
| 30 | Shows product name, current version, authors, and link to the product page. |
---|
| 31 | """ |
---|
| 32 | ## Internal nickname for the window, used by the AUI manager |
---|
| 33 | window_name = "default" |
---|
| 34 | ## Name to appear on the window title bar |
---|
| 35 | window_caption = "Welcome panel" |
---|
| 36 | ## Flag to tell the AUI manager to put this panel in the center pane |
---|
| 37 | CENTER_PANE = True |
---|
| 38 | |
---|
| 39 | |
---|
[c363d74] | 40 | def __init__(self,parent, *args, **kwds): |
---|
[9455d77] | 41 | |
---|
| 42 | kwds["style"] = wx.aui.AUI_NB_DEFAULT_STYLE |
---|
| 43 | |
---|
| 44 | wx.aui.AuiNotebook.__init__(self, parent, *args, **kwds) |
---|
| 45 | #For sansview the parent is guiframe |
---|
| 46 | self.parent = parent |
---|
[c363d74] | 47 | |
---|
[9455d77] | 48 | welcome_page = WelcomePage(self) |
---|
| 49 | self.AddPage(page=welcome_page, caption="Welcome") |
---|
| 50 | |
---|
| 51 | pageClosedEvent = wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE |
---|
| 52 | self.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.on_close_page) |
---|
| 53 | self.Center() |
---|
[f1aa385] | 54 | |
---|
[9455d77] | 55 | def set_manager(self, manager): |
---|
| 56 | """ |
---|
| 57 | the manager of the panel in this case the application itself |
---|
| 58 | """ |
---|
| 59 | self.manager = manager |
---|
| 60 | |
---|
| 61 | def on_close_page(self, event): |
---|
| 62 | """ |
---|
| 63 | |
---|
| 64 | """ |
---|
| 65 | if self.parent is not None: |
---|
| 66 | self.parent.on_close_welcome_panel() |
---|
| 67 | event.Veto() |
---|
| 68 | |
---|
| 69 | class WelcomePage(wx.Panel): |
---|
[e2da832] | 70 | """ |
---|
| 71 | Panel created like about box as a welcome page |
---|
| 72 | Shows product name, current version, authors, and link to the product page. |
---|
| 73 | """ |
---|
| 74 | ## Internal nickname for the window, used by the AUI manager |
---|
| 75 | window_name = "default" |
---|
| 76 | ## Name to appear on the window title bar |
---|
| 77 | window_caption = "Welcome panel" |
---|
| 78 | ## Flag to tell the AUI manager to put this panel in the center pane |
---|
| 79 | CENTER_PANE = True |
---|
[f1aa385] | 80 | |
---|
[e2da832] | 81 | |
---|
| 82 | def __init__(self, *args, **kwds): |
---|
| 83 | |
---|
| 84 | kwds["style"] = wx.DEFAULT_DIALOG_STYLE |
---|
| 85 | |
---|
| 86 | wx.Panel.__init__(self, *args, **kwds) |
---|
| 87 | |
---|
[ea2aa224] | 88 | image = os.path.join("images","SVwelcome.png") |
---|
[e2da832] | 89 | |
---|
[f1aa385] | 90 | self.SetWindowVariant(variant = FONT_VARIANT) |
---|
[e2da832] | 91 | self.bitmap_logo = wx.StaticBitmap(self, -1, wx.Bitmap(image)) |
---|
| 92 | |
---|
| 93 | self.label_copyright = wx.StaticText(self, -1, config._copyright) |
---|
| 94 | self.static_line_1 = wx.StaticLine(self, -1) |
---|
| 95 | self.label_acknowledgement = wx.StaticText(self, -1, config._acknowledgement) |
---|
| 96 | |
---|
| 97 | self.hyperlink_license = wx.StaticText(self, -1, "Comments? Bugs? Requests?") |
---|
| 98 | self.hyperlink_paper = wx.lib.hyperlink.HyperLinkCtrl(self, -1, |
---|
| 99 | "Send us a ticket",URL=config._license) |
---|
| 100 | |
---|
| 101 | verwords = config.__version__.split('.') |
---|
| 102 | version = '.'.join(verwords[:-1]) |
---|
| 103 | revision = verwords[-1] |
---|
| 104 | self.label_title = wx.StaticText(self, -1, config.__appname__+ " "+str(config.__version__))#(version)) |
---|
| 105 | self.label_build = wx.StaticText(self, -1, "Build: "+str(config.__version__)) |
---|
| 106 | |
---|
| 107 | sizer_main = wx.BoxSizer(wx.VERTICAL) |
---|
| 108 | sizer_header = wx.BoxSizer(wx.HORIZONTAL) |
---|
| 109 | sizer_build = wx.BoxSizer(wx.VERTICAL) |
---|
| 110 | |
---|
| 111 | sizer_header.Add(self.bitmap_logo, 0, wx.EXPAND|wx.LEFT, 5) |
---|
| 112 | |
---|
| 113 | sizer_build.Add(self.label_acknowledgement,0,wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 114 | sizer_build.Add((5,5)) |
---|
| 115 | sizer_build.Add(self.label_title ,0,wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 116 | sizer_build.Add(self.label_build,0,wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 117 | sizer_build.Add( self.label_copyright,0,wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 118 | sizer_build.Add((5,5)) |
---|
| 119 | sizer_build.Add( self.hyperlink_license,0,wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 120 | sizer_build.Add( self.hyperlink_paper,0,wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 121 | |
---|
| 122 | sizer_main.Add(sizer_header, 0, wx.TOP|wx.EXPAND, 3) |
---|
| 123 | sizer_main.Add(self.static_line_1, 0, wx.EXPAND, 0) |
---|
| 124 | sizer_main.Add(sizer_build,0, wx.BOTTOM|wx.EXPAND, 3) |
---|
| 125 | |
---|
| 126 | self.SetAutoLayout(True) |
---|
| 127 | self.SetSizer(sizer_main) |
---|
| 128 | self.Fit() |
---|
| 129 | |
---|
| 130 | |
---|
| 131 | class ViewApp(wx.App): |
---|
| 132 | def OnInit(self): |
---|
| 133 | self.frame = WelcomeFrame(None, -1, "Test App") |
---|
| 134 | self.frame.Show(True) |
---|
| 135 | return True |
---|
| 136 | |
---|
| 137 | class WelcomeFrame(wx.Frame): |
---|
| 138 | def __init__(self, parent, id, title): |
---|
| 139 | wx.Frame.__init__(self, parent, id, title, size=(570, 400)) |
---|
| 140 | WelcomePanel(self) |
---|
| 141 | self.Centre() |
---|
| 142 | self.Show(True) |
---|
| 143 | |
---|
| 144 | if __name__ == "__main__": |
---|
| 145 | app = ViewApp(0) |
---|
| 146 | app.MainLoop() |
---|