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