[09d8c94] | 1 | #!/usr/bin/env python |
---|
| 2 | ######################################################################## |
---|
| 3 | # |
---|
| 4 | # PDFgui by DANSE Diffraction group |
---|
| 5 | # Simon J. L. Billinge |
---|
| 6 | # (c) 2006 trustees of the Michigan State University. |
---|
| 7 | # All rights reserved. |
---|
| 8 | # |
---|
| 9 | # File coded by: Dmitriy Bryndin |
---|
| 10 | # |
---|
| 11 | # See AUTHORS.txt for a list of people who contributed. |
---|
| 12 | # See LICENSE.txt for license information. |
---|
| 13 | # |
---|
| 14 | # Modified by U. Tennessee for DANSE/SANS |
---|
| 15 | ######################################################################## |
---|
| 16 | |
---|
| 17 | # version |
---|
| 18 | __id__ = "$Id: aboutdialog.py 1193 2007-05-03 17:29:59Z dmitriy $" |
---|
| 19 | __revision__ = "$Revision: 1193 $" |
---|
| 20 | |
---|
| 21 | import wx |
---|
| 22 | import wx.lib.hyperlink |
---|
| 23 | import random |
---|
| 24 | import os.path |
---|
| 25 | import os |
---|
| 26 | try: |
---|
| 27 | # Try to find a local config |
---|
| 28 | import imp |
---|
| 29 | path = os.getcwd() |
---|
| 30 | if(os.path.isfile("%s/%s.py" % (path, 'local_config'))) or \ |
---|
| 31 | (os.path.isfile("%s/%s.pyc" % (path, 'local_config'))): |
---|
| 32 | fObj, path, descr = imp.find_module('local_config', [path]) |
---|
| 33 | config = imp.load_module('local_config', fObj, path, descr) |
---|
| 34 | else: |
---|
| 35 | # Try simply importing local_config |
---|
| 36 | import local_config as config |
---|
| 37 | except: |
---|
| 38 | # Didn't find local config, load the default |
---|
| 39 | import config |
---|
| 40 | |
---|
| 41 | def launchBrowser(url): |
---|
| 42 | '''Launches browser and opens specified url |
---|
| 43 | |
---|
| 44 | In some cases may require BROWSER environment variable to be set up. |
---|
| 45 | |
---|
| 46 | @param url: URL to open |
---|
| 47 | ''' |
---|
| 48 | import webbrowser |
---|
| 49 | webbrowser.open(url) |
---|
| 50 | |
---|
| 51 | |
---|
| 52 | class PanelAbout(wx.Panel): |
---|
| 53 | '''"About" Dialog |
---|
| 54 | |
---|
| 55 | Shows product name, current version, authors, and link to the product page. |
---|
| 56 | Current version is taken from version.py |
---|
| 57 | ''' |
---|
| 58 | |
---|
| 59 | def __init__(self, *args, **kwds): |
---|
| 60 | |
---|
| 61 | # begin wxGlade: DialogAbout.__init__ |
---|
| 62 | kwds["style"] = wx.DEFAULT_DIALOG_STYLE |
---|
| 63 | |
---|
| 64 | wx.Panel.__init__(self, *args, **kwds) |
---|
| 65 | |
---|
| 66 | file_dir = os.path.dirname(__file__) |
---|
| 67 | |
---|
| 68 | # Mac doesn't display images with transparent background so well, keep it for Windows |
---|
| 69 | image = file_dir+"/images/SVwelcome.png" |
---|
| 70 | |
---|
| 71 | if os.name == 'nt': |
---|
| 72 | self.bitmap_logo = wx.StaticBitmap(self, -1, wx.Bitmap(image)) |
---|
| 73 | else: |
---|
| 74 | self.bitmap_logo = wx.StaticBitmap(self, -1, wx.Bitmap(image)) |
---|
| 75 | |
---|
| 76 | self.label_copyright = wx.StaticText(self, -1, config._copyright) |
---|
| 77 | |
---|
| 78 | self.static_line_1 = wx.StaticLine(self, -1) |
---|
| 79 | self.label_acknowledgement = wx.StaticText(self, -1, config._acknowledgement) |
---|
| 80 | |
---|
| 81 | |
---|
| 82 | |
---|
| 83 | |
---|
| 84 | # end wxGlade |
---|
| 85 | |
---|
| 86 | # |
---|
| 87 | # randomly shuffle authors' names |
---|
| 88 | random.shuffle(config._authors) |
---|
| 89 | strLabel = ", ".join(config._authors) |
---|
| 90 | |
---|
| 91 | # display version and svn revison numbers |
---|
| 92 | verwords = config.__version__.split('.') |
---|
| 93 | version = '.'.join(verwords[:-1]) |
---|
| 94 | revision = verwords[-1] |
---|
| 95 | self.label_title = wx.StaticText(self, -1, config.__appname__+ " "+str(version)) |
---|
| 96 | self.label_build = wx.StaticText(self, -1, "Build: "+str(config.__version__)) |
---|
| 97 | |
---|
| 98 | |
---|
| 99 | # resize dialog window to fit version number nicely |
---|
| 100 | if wx.VERSION >= (2,7,2,0): |
---|
| 101 | size = [self.GetEffectiveMinSize()[0], self.GetSize()[1]] |
---|
| 102 | else: |
---|
| 103 | size = [self.GetBestFittingSize()[0], self.GetSize()[1]] |
---|
| 104 | self.__do_layout() |
---|
| 105 | self.Fit() |
---|
| 106 | |
---|
| 107 | |
---|
| 108 | |
---|
| 109 | def __do_layout(self): |
---|
| 110 | # begin wxGlade: DialogAbout.__do_layout |
---|
| 111 | sizer_main = wx.BoxSizer(wx.VERTICAL) |
---|
| 112 | sizer_header = wx.BoxSizer(wx.HORIZONTAL) |
---|
| 113 | sizer_build = wx.GridBagSizer(0,0) |
---|
| 114 | |
---|
| 115 | |
---|
| 116 | sizer_header.Add(self.bitmap_logo, 0, wx.EXPAND|wx.LEFT, 5) |
---|
| 117 | |
---|
| 118 | ix = 0 |
---|
| 119 | iy = 0 |
---|
| 120 | sizer_build.Add((20,20),(iy,ix),(1,1),wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 121 | iy +=1 |
---|
| 122 | sizer_build.Add(self.label_acknowledgement,(iy,ix),(1,1),wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 123 | iy +=1 |
---|
| 124 | sizer_build.Add(self.label_title ,(iy,ix),(1,1),wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 125 | ix = 0 |
---|
| 126 | iy +=1 |
---|
| 127 | sizer_build.Add(self.label_build,(iy,ix),(1,1),wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 128 | ix = 0 |
---|
| 129 | iy +=1 |
---|
| 130 | sizer_build.Add( self.label_copyright,(iy,ix),(1,1),wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 131 | |
---|
| 132 | sizer_main.Add(sizer_header, 0, wx.TOP|wx.EXPAND, 3) |
---|
| 133 | sizer_main.Add(self.static_line_1, 0, wx.EXPAND, 0) |
---|
| 134 | sizer_main.Add(sizer_build,0, wx.BOTTOM|wx.EXPAND, 3) |
---|
| 135 | |
---|
| 136 | |
---|
| 137 | self.SetAutoLayout(True) |
---|
| 138 | self.SetSizer(sizer_main) |
---|
| 139 | self.Layout() |
---|
| 140 | self.Centre() |
---|
| 141 | # end wxGlade |
---|
| 142 | |
---|
| 143 | |
---|
| 144 | |
---|
| 145 | # end of class DialogAbout |
---|
| 146 | |
---|