[0690e1d] | 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/angles_flat.png" |
---|
| 70 | if os.path.isfile(config._corner_image): |
---|
| 71 | image = config._corner_image |
---|
| 72 | |
---|
| 73 | if os.name == 'nt': |
---|
| 74 | self.bitmap_logo = wx.StaticBitmap(self, -1, wx.Bitmap(image)) |
---|
| 75 | else: |
---|
| 76 | self.bitmap_logo = wx.StaticBitmap(self, -1, wx.Bitmap(image)) |
---|
[d468daa] | 77 | self.bitmap_logo.SetFocus() |
---|
[0690e1d] | 78 | self.label_title = wx.StaticText(self, -1, config.__appname__) |
---|
| 79 | self.label_version = wx.StaticText(self, -1, "") |
---|
| 80 | self.label_build = wx.StaticText(self, -1, "Build:") |
---|
| 81 | self.label_svnrevision = wx.StaticText(self, -1, "") |
---|
| 82 | self.label_copyright = wx.StaticText(self, -1, config._copyright) |
---|
| 83 | self.label_author = wx.StaticText(self, -1, "authors") |
---|
[53087f2] | 84 | self.hyperlink = wx.StaticText(self, -1, str(config._homepage)) |
---|
| 85 | #self.hyperlink = wx.lib.hyperlink.HyperLinkCtrl(self, -1, config._homepage, URL=config._homepage) |
---|
[0690e1d] | 86 | #self.hyperlink_license = wx.lib.hyperlink.HyperLinkCtrl(self, -1, "Comments? Bugs? Requests?", URL=config._paper) |
---|
| 87 | self.hyperlink_license = wx.StaticText(self, -1, "Comments? Bugs? Requests?") |
---|
[53087f2] | 88 | self.hyperlink_paper = wx.StaticText(self, -1, str(config._license)) |
---|
| 89 | #self.hyperlink_paper = wx.lib.hyperlink.HyperLinkCtrl(self, -1, "Send us a ticket", URL=config._license) |
---|
| 90 | |
---|
| 91 | self.hyperlink_download = wx.StaticText(self, -1, str(config._download)) |
---|
| 92 | #self.hyperlink_download = wx.lib.hyperlink.HyperLinkCtrl(self, -1, "Get the latest version", URL=config._download) |
---|
[0690e1d] | 93 | self.static_line_1 = wx.StaticLine(self, -1) |
---|
| 94 | self.label_acknowledgement = wx.StaticText(self, -1, config._acknowledgement) |
---|
| 95 | self.static_line_2 = wx.StaticLine(self, -1) |
---|
| 96 | self.bitmap_button_nsf = wx.BitmapButton(self, -1, wx.NullBitmap) |
---|
| 97 | self.bitmap_button_danse = wx.BitmapButton(self, -1, wx.NullBitmap) |
---|
| 98 | self.bitmap_button_msu = wx.BitmapButton(self, -1, wx.NullBitmap) |
---|
| 99 | |
---|
| 100 | |
---|
| 101 | self.__set_properties() |
---|
| 102 | self.__do_layout() |
---|
| 103 | |
---|
| 104 | # end wxGlade |
---|
| 105 | |
---|
| 106 | # fill in acknowledgements |
---|
| 107 | # self.text_ctrl_acknowledgement.SetValue(__acknowledgement__) |
---|
| 108 | |
---|
| 109 | # randomly shuffle authors' names |
---|
| 110 | random.shuffle(config._authors) |
---|
| 111 | strLabel = ", ".join(config._authors) |
---|
| 112 | |
---|
| 113 | # display version and svn revison numbers |
---|
| 114 | verwords = config.__version__.split('.') |
---|
| 115 | version = '.'.join(verwords[:-1]) |
---|
| 116 | revision = verwords[-1] |
---|
| 117 | |
---|
| 118 | self.label_author.SetLabel(strLabel) |
---|
| 119 | self.label_version.SetLabel(version) |
---|
| 120 | self.label_svnrevision.SetLabel(config.__version__) |
---|
| 121 | |
---|
| 122 | # set bitmaps for logo buttons |
---|
| 123 | image = file_dir+"/images/nsf_logo.png" |
---|
| 124 | if os.path.isfile(config._nsf_logo): |
---|
| 125 | image = config._nsf_logo |
---|
| 126 | logo = wx.Bitmap(image) |
---|
| 127 | self.bitmap_button_nsf.SetBitmapLabel(logo) |
---|
| 128 | |
---|
| 129 | image = file_dir+"/images/danse_logo.png" |
---|
| 130 | if os.path.isfile(config._danse_logo): |
---|
| 131 | image = config._danse_logo |
---|
| 132 | logo = wx.Bitmap(image) |
---|
| 133 | self.bitmap_button_danse.SetBitmapLabel(logo) |
---|
| 134 | |
---|
| 135 | image = file_dir+"/images/utlogo.gif" |
---|
| 136 | if os.path.isfile(config._inst_logo): |
---|
| 137 | image = config._inst_logo |
---|
| 138 | logo = wx.Bitmap(image) |
---|
| 139 | self.bitmap_button_msu.SetBitmapLabel(logo) |
---|
| 140 | |
---|
| 141 | # resize dialog window to fit version number nicely |
---|
| 142 | if wx.VERSION >= (2,7,2,0): |
---|
| 143 | size = [self.GetEffectiveMinSize()[0], self.GetSize()[1]] |
---|
| 144 | else: |
---|
| 145 | size = [self.GetBestFittingSize()[0], self.GetSize()[1]] |
---|
| 146 | |
---|
| 147 | self.Fit() |
---|
| 148 | # self.SetSize(size) |
---|
| 149 | # self.FitInside() |
---|
| 150 | |
---|
| 151 | |
---|
| 152 | def __set_properties(self): |
---|
| 153 | # begin wxGlade: DialogAbout.__set_properties |
---|
| 154 | |
---|
| 155 | self.SetSize((600, 595)) |
---|
| 156 | self.label_title.SetFont(wx.Font(26, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, "")) |
---|
| 157 | self.label_version.SetFont(wx.Font(26, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "")) |
---|
| 158 | #self.hyperlink_license.Enable(False) |
---|
| 159 | #self.hyperlink_license.Hide() |
---|
| 160 | self.hyperlink_paper.Enable(True) |
---|
| 161 | #self.hyperlink_paper.Hide() |
---|
| 162 | self.bitmap_button_nsf.SetSize(self.bitmap_button_nsf.GetBestSize()) |
---|
| 163 | self.bitmap_button_danse.SetSize(self.bitmap_button_danse.GetBestSize()) |
---|
| 164 | self.bitmap_button_msu.SetSize(self.bitmap_button_msu.GetBestSize()) |
---|
| 165 | # end wxGlade |
---|
| 166 | |
---|
| 167 | def __do_layout(self): |
---|
| 168 | # begin wxGlade: DialogAbout.__do_layout |
---|
| 169 | sizer_main = wx.BoxSizer(wx.VERTICAL) |
---|
| 170 | |
---|
| 171 | sizer_logos = wx.BoxSizer(wx.HORIZONTAL) |
---|
| 172 | sizer_header = wx.BoxSizer(wx.HORIZONTAL) |
---|
| 173 | sizer_titles = wx.BoxSizer(wx.VERTICAL) |
---|
| 174 | sizer_build = wx.BoxSizer(wx.HORIZONTAL) |
---|
| 175 | sizer_title = wx.BoxSizer(wx.HORIZONTAL) |
---|
| 176 | sizer_header.Add(self.bitmap_logo, 0, wx.EXPAND, 0) |
---|
| 177 | sizer_title.Add(self.label_title, 0, wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) |
---|
| 178 | sizer_title.Add((20, 20), 0, wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 179 | sizer_title.Add(self.label_version, 0, wx.RIGHT|wx.ALIGN_BOTTOM|wx.ADJUST_MINSIZE, 10) |
---|
| 180 | sizer_titles.Add(sizer_title, 0, wx.EXPAND, 0) |
---|
| 181 | sizer_build.Add(self.label_build, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10) |
---|
| 182 | sizer_build.Add(self.label_svnrevision, 0, wx.ADJUST_MINSIZE, 0) |
---|
| 183 | sizer_titles.Add(sizer_build, 0, wx.TOP|wx.EXPAND, 5) |
---|
| 184 | sizer_titles.Add(self.label_copyright, 0, wx.LEFT|wx.RIGHT|wx.TOP|wx.ADJUST_MINSIZE, 10) |
---|
| 185 | sizer_titles.Add(self.label_author, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10) |
---|
| 186 | sizer_titles.Add(self.hyperlink, 0, wx.LEFT|wx.RIGHT, 10) |
---|
| 187 | sizer_titles.Add((20, 20), 0, wx.ADJUST_MINSIZE, 0) |
---|
| 188 | sizer_titles.Add(self.hyperlink_license, 0, wx.LEFT|wx.RIGHT, 10) |
---|
| 189 | sizer_titles.Add(self.hyperlink_paper, 0, wx.LEFT|wx.RIGHT, 10) |
---|
| 190 | sizer_titles.Add((20, 20), 0, wx.ADJUST_MINSIZE, 0) |
---|
| 191 | sizer_titles.Add(self.hyperlink_download, 0, wx.LEFT|wx.RIGHT, 10) |
---|
| 192 | sizer_header.Add(sizer_titles, 0, wx.EXPAND, 0) |
---|
| 193 | sizer_main.Add(sizer_header, 0, wx.BOTTOM|wx.EXPAND, 3) |
---|
| 194 | sizer_main.Add(self.static_line_1, 0, wx.EXPAND, 0) |
---|
| 195 | sizer_main.Add(self.label_acknowledgement, 0, wx.LEFT|wx.TOP|wx.BOTTOM|wx.ADJUST_MINSIZE, 7) |
---|
| 196 | sizer_main.Add(self.static_line_2, 0, wx.EXPAND, 0) |
---|
| 197 | sizer_logos.Add(self.bitmap_button_nsf, 0, wx.LEFT|wx.ADJUST_MINSIZE, 2) |
---|
| 198 | sizer_logos.Add(self.bitmap_button_danse, 0, wx.LEFT|wx.ADJUST_MINSIZE, 2) |
---|
| 199 | sizer_logos.Add(self.bitmap_button_msu, 0, wx.LEFT|wx.ADJUST_MINSIZE, 2) |
---|
| 200 | sizer_logos.Add((50, 50), 0, wx.ADJUST_MINSIZE, 0) |
---|
| 201 | sizer_main.Add(sizer_logos, 0, wx.EXPAND, 0) |
---|
| 202 | |
---|
| 203 | self.SetAutoLayout(True) |
---|
| 204 | self.SetSizer(sizer_main) |
---|
| 205 | self.Layout() |
---|
| 206 | self.Centre() |
---|
| 207 | # end wxGlade |
---|
| 208 | |
---|
[53087f2] | 209 | |
---|
[0690e1d] | 210 | |
---|
| 211 | # end of class DialogAbout |
---|
| 212 | |
---|