[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 |
---|
[60642b4] | 20 | import logging |
---|
[4ff124ad] | 21 | from wx.lib.scrolledpanel import ScrolledPanel |
---|
[c8deee5] | 22 | from sans.guiframe.panel_base import PanelBase |
---|
[f1aa385] | 23 | #Font size width |
---|
| 24 | if sys.platform.count("win32")>0: |
---|
| 25 | FONT_VARIANT = 0 |
---|
| 26 | else: |
---|
| 27 | FONT_VARIANT = 1 |
---|
[9455d77] | 28 | |
---|
[c8deee5] | 29 | class WelcomePanel(wx.aui.AuiNotebook, PanelBase): |
---|
[9455d77] | 30 | """ |
---|
| 31 | Panel created like about box as a welcome page |
---|
| 32 | Shows product name, current version, authors, and link to the product page. |
---|
| 33 | """ |
---|
| 34 | ## Internal nickname for the window, used by the AUI manager |
---|
| 35 | window_name = "default" |
---|
| 36 | ## Name to appear on the window title bar |
---|
| 37 | window_caption = "Welcome panel" |
---|
| 38 | ## Flag to tell the AUI manager to put this panel in the center pane |
---|
| 39 | CENTER_PANE = True |
---|
| 40 | |
---|
| 41 | |
---|
[c363d74] | 42 | def __init__(self,parent, *args, **kwds): |
---|
[9455d77] | 43 | |
---|
| 44 | kwds["style"] = wx.aui.AUI_NB_DEFAULT_STYLE |
---|
| 45 | |
---|
| 46 | wx.aui.AuiNotebook.__init__(self, parent, *args, **kwds) |
---|
[c8deee5] | 47 | PanelBase.__init__(self) |
---|
[9455d77] | 48 | #For sansview the parent is guiframe |
---|
| 49 | self.parent = parent |
---|
[c363d74] | 50 | |
---|
[9455d77] | 51 | welcome_page = WelcomePage(self) |
---|
| 52 | self.AddPage(page=welcome_page, caption="Welcome") |
---|
| 53 | |
---|
| 54 | pageClosedEvent = wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE |
---|
| 55 | self.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.on_close_page) |
---|
| 56 | self.Center() |
---|
[f1aa385] | 57 | |
---|
[9455d77] | 58 | def set_manager(self, manager): |
---|
| 59 | """ |
---|
| 60 | the manager of the panel in this case the application itself |
---|
| 61 | """ |
---|
| 62 | self.manager = manager |
---|
| 63 | |
---|
| 64 | def on_close_page(self, event): |
---|
| 65 | """ |
---|
| 66 | |
---|
| 67 | """ |
---|
| 68 | if self.parent is not None: |
---|
| 69 | self.parent.on_close_welcome_panel() |
---|
| 70 | event.Veto() |
---|
[3c44c66] | 71 | |
---|
| 72 | def set_data(self, list=[]): |
---|
| 73 | """ |
---|
| 74 | """ |
---|
| 75 | pass |
---|
| 76 | |
---|
| 77 | |
---|
[4ff124ad] | 78 | class WelcomePage(ScrolledPanel): |
---|
[e2da832] | 79 | """ |
---|
| 80 | Panel created like about box as a welcome page |
---|
| 81 | Shows product name, current version, authors, and link to the product page. |
---|
| 82 | """ |
---|
| 83 | ## Internal nickname for the window, used by the AUI manager |
---|
| 84 | window_name = "default" |
---|
| 85 | ## Name to appear on the window title bar |
---|
| 86 | window_caption = "Welcome panel" |
---|
| 87 | ## Flag to tell the AUI manager to put this panel in the center pane |
---|
| 88 | CENTER_PANE = True |
---|
[f1aa385] | 89 | |
---|
[e2da832] | 90 | |
---|
[4ff124ad] | 91 | def __init__(self, parent, *args, **kwds): |
---|
[e2da832] | 92 | |
---|
| 93 | kwds["style"] = wx.DEFAULT_DIALOG_STYLE |
---|
| 94 | |
---|
[4ff124ad] | 95 | ScrolledPanel.__init__(self, parent, **kwds) |
---|
| 96 | self.SetupScrolling() |
---|
[93f7c62] | 97 | image = os.path.join("images","SVwelcome.png") |
---|
[f1aa385] | 98 | self.SetWindowVariant(variant = FONT_VARIANT) |
---|
[e2da832] | 99 | self.bitmap_logo = wx.StaticBitmap(self, -1, wx.Bitmap(image)) |
---|
| 100 | |
---|
| 101 | self.label_copyright = wx.StaticText(self, -1, config._copyright) |
---|
| 102 | self.static_line_1 = wx.StaticLine(self, -1) |
---|
| 103 | self.label_acknowledgement = wx.StaticText(self, -1, config._acknowledgement) |
---|
| 104 | |
---|
| 105 | self.hyperlink_license = wx.StaticText(self, -1, "Comments? Bugs? Requests?") |
---|
| 106 | self.hyperlink_paper = wx.lib.hyperlink.HyperLinkCtrl(self, -1, |
---|
[efea0bd] | 107 | "Send us a ticket at: sansdanse@gmail.com",URL=config._license) |
---|
[e2da832] | 108 | |
---|
| 109 | verwords = config.__version__.split('.') |
---|
| 110 | version = '.'.join(verwords[:-1]) |
---|
| 111 | revision = verwords[-1] |
---|
| 112 | self.label_title = wx.StaticText(self, -1, config.__appname__+ " "+str(config.__version__))#(version)) |
---|
| 113 | self.label_build = wx.StaticText(self, -1, "Build: "+str(config.__version__)) |
---|
| 114 | |
---|
| 115 | sizer_main = wx.BoxSizer(wx.VERTICAL) |
---|
| 116 | sizer_header = wx.BoxSizer(wx.HORIZONTAL) |
---|
| 117 | sizer_build = wx.BoxSizer(wx.VERTICAL) |
---|
| 118 | |
---|
| 119 | sizer_header.Add(self.bitmap_logo, 0, wx.EXPAND|wx.LEFT, 5) |
---|
| 120 | |
---|
| 121 | sizer_build.Add(self.label_acknowledgement,0,wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 122 | sizer_build.Add((5,5)) |
---|
| 123 | sizer_build.Add(self.label_title ,0,wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 124 | sizer_build.Add(self.label_build,0,wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 125 | sizer_build.Add( self.label_copyright,0,wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 126 | sizer_build.Add((5,5)) |
---|
| 127 | sizer_build.Add( self.hyperlink_license,0,wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 128 | sizer_build.Add( self.hyperlink_paper,0,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() |
---|
[3c44c66] | 137 | |
---|
| 138 | def set_data(self, list=[]): |
---|
| 139 | """ |
---|
| 140 | """ |
---|
| 141 | pass |
---|
[e2da832] | 142 | |
---|
| 143 | class ViewApp(wx.App): |
---|
| 144 | def OnInit(self): |
---|
| 145 | self.frame = WelcomeFrame(None, -1, "Test App") |
---|
| 146 | self.frame.Show(True) |
---|
| 147 | return True |
---|
| 148 | |
---|
| 149 | class WelcomeFrame(wx.Frame): |
---|
| 150 | def __init__(self, parent, id, title): |
---|
| 151 | wx.Frame.__init__(self, parent, id, title, size=(570, 400)) |
---|
| 152 | WelcomePanel(self) |
---|
| 153 | self.Centre() |
---|
| 154 | self.Show(True) |
---|
| 155 | |
---|
| 156 | if __name__ == "__main__": |
---|
| 157 | app = ViewApp(0) |
---|
| 158 | app.MainLoop() |
---|