source: sasview/src/sas/sasgui/guiframe/aboutbox.py @ 1779e72

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.2.2ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 1779e72 was 1779e72, checked in by smk78, 7 years ago

Incorporated DLS logo and URL, and added DLS to list of institutional
contributors. Closes #913

  • Property mode set to 100644
File size: 18.6 KB
Line 
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
21import wx
22import wx.lib.hyperlink
23import random
24import os.path
25import os
26try:
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
37except:
38    # Didn't find local config, load the default
39    import config
40
41def launchBrowser(url):
42    """
43    Launches browser and opens specified url
44   
45    In some cases may require BROWSER environment variable to be set up.
46   
47    :param url: URL to open
48   
49    """
50    import webbrowser
51    webbrowser.open(url)
52
53
54class DialogAbout(wx.Dialog):
55    """
56    "About" Dialog
57   
58    Shows product name, current version, authors, and link to the product page.
59    Current version is taken from version.py
60   
61    """
62   
63    def __init__(self, *args, **kwds):
64
65        # begin wxGlade: DialogAbout.__init__
66        kwds["style"] = wx.DEFAULT_DIALOG_STYLE
67        wx.Dialog.__init__(self, *args, **kwds)
68       
69        file_dir = os.path.dirname(__file__)
70       
71        # Mac doesn't display images with transparent background so well,
72        # keep it for Windows
73        image = file_dir + "/images/angles_flat.png"
74       
75        if os.path.isfile(config._corner_image):
76            image = config._corner_image
77
78        if os.name == 'nt':
79            self.bitmap_logo = wx.StaticBitmap(self, -1, wx.Bitmap(image))
80        else:
81            self.bitmap_logo = wx.StaticBitmap(self, -1, wx.Bitmap(image))
82       
83        self.label_title = wx.StaticText(self, -1, config.__appname__)
84        self.label_version = wx.StaticText(self, -1, "")
85        self.label_build = wx.StaticText(self, -1, "Build:")
86        self.label_svnrevision = wx.StaticText(self, -1, "")
87        self.label_copyright = wx.StaticText(self, -1, config._copyright)
88        self.label_author = wx.StaticText(self, -1, "authors")
89        self.hyperlink = wx.lib.hyperlink.HyperLinkCtrl(self, -1,
90                                                        config._homepage,
91                                                        URL=config._homepage)
92        #self.hyperlink_license = wx.lib.hyperlink.HyperLinkCtrl(self, -1,
93        #"Comments? Bugs? Requests?", URL=config._paper)
94        self.hyperlink_license = wx.StaticText(self, -1,
95                                               "Comments? Bugs? Requests?")
96        self.hyperlink_paper = wx.lib.hyperlink.HyperLinkCtrl(self, -1,
97                                                        "Send us a ticket",
98                                                        URL=config._license)
99        self.hyperlink_download = wx.lib.hyperlink.HyperLinkCtrl(self, -1,
100                                                "Get the latest version",
101                                                URL=config._download)
102        self.static_line_1 = wx.StaticLine(self, -1)
103        self.label_acknowledgement = wx.StaticText(self, -1,
104                                                   config._acknowledgement)
105        self.static_line_2 = wx.StaticLine(self, -1)
106        self.bitmap_button_nist = wx.BitmapButton(self, -1, wx.NullBitmap)
107        self.bitmap_button_umd = wx.BitmapButton(self, -1, wx.NullBitmap)
108        self.bitmap_button_ornl = wx.BitmapButton(self, -1, wx.NullBitmap)
109        #self.bitmap_button_sns = wx.BitmapButton(self, -1, wx.NullBitmap)
110        #self.bitmap_button_nsf = wx.BitmapButton(self, -1,
111        #                                         wx.NullBitmap)
112        #self.bitmap_button_danse = wx.BitmapButton(self, -1, wx.NullBitmap)
113        self.bitmap_button_msu = wx.BitmapButton(self, -1, wx.NullBitmap)
114       
115        self.bitmap_button_isis = wx.BitmapButton(self, -1, wx.NullBitmap)
116        self.bitmap_button_ess = wx.BitmapButton(self, -1, wx.NullBitmap)
117        self.bitmap_button_ill = wx.BitmapButton(self, -1, wx.NullBitmap)
118        self.bitmap_button_ansto = wx.BitmapButton(self, -1, wx.NullBitmap)
119        self.bitmap_button_tudelft = wx.BitmapButton(self, -1, wx.NullBitmap)
120        self.bitmap_button_dls = wx.BitmapButton(self, -1, wx.NullBitmap)
121       
122        self.static_line_3 = wx.StaticLine(self, -1)
123        self.button_OK = wx.Button(self, wx.ID_OK, "OK")
124
125        self.__set_properties()
126        self.__do_layout()
127       
128        self.Bind(wx.EVT_BUTTON, self.onNistLogo, self.bitmap_button_nist)
129        self.Bind(wx.EVT_BUTTON, self.onUmdLogo, self.bitmap_button_umd)
130        #self.Bind(wx.EVT_BUTTON, self.onSnsLogo, self.bitmap_button_sns)
131        self.Bind(wx.EVT_BUTTON, self.onOrnlLogo, self.bitmap_button_ornl)
132        #self.Bind(wx.EVT_BUTTON, self.onNsfLogo, self.bitmap_button_nsf)
133        #self.Bind(wx.EVT_BUTTON, self.onDanseLogo, self.bitmap_button_danse)
134        self.Bind(wx.EVT_BUTTON, self.onUTLogo, self.bitmap_button_msu)
135        self.Bind(wx.EVT_BUTTON, self.onIsisLogo, self.bitmap_button_isis)
136        self.Bind(wx.EVT_BUTTON, self.onEssLogo, self.bitmap_button_ess)
137        self.Bind(wx.EVT_BUTTON, self.onIllLogo, self.bitmap_button_ill)
138        self.Bind(wx.EVT_BUTTON, self.onAnstoLogo, self.bitmap_button_ansto)
139        self.Bind(wx.EVT_BUTTON, self.onTudelftLogo, self.bitmap_button_tudelft)
140        self.Bind(wx.EVT_BUTTON, self.onDlsLogo, self.bitmap_button_dls)
141        # end wxGlade
142        # fill in acknowledgements
143        #self.text_ctrl_acknowledgement.SetValue(__acknowledgement__)
144        # randomly shuffle authors' names
145        random.shuffle(config._authors)
146        strLabel = ", ".join(config._authors)
147       
148        # display version and svn revison numbers
149        verwords = config.__version__.split('.')
150        version = '.'.join(verwords[:-1])
151        revision = verwords[-1]
152        try:
153            build_num = str(config.__build__)
154        except:
155            build_num = str(config.__version__)
156        self.label_author.SetLabel(strLabel)
157        self.label_version.SetLabel(config.__version__)#(version)
158        self.label_svnrevision.SetLabel(build_num)
159       
160        # set bitmaps for logo buttons
161        image = file_dir + "/images/nist_logo.png"
162        if os.path.isfile(config._nist_logo):
163            image = config._nist_logo
164        logo = wx.Bitmap(image)       
165        self.bitmap_button_nist.SetBitmapLabel(logo)
166       
167        image = file_dir + "/images/umd_logo.png"
168        if os.path.isfile(config._umd_logo):
169            image = config._umd_logo
170        logo = wx.Bitmap(image)       
171        self.bitmap_button_umd.SetBitmapLabel(logo)
172
173        image = file_dir + "/images/ornl_logo.png"
174        if os.path.isfile(config._ornl_logo):
175            image = config._ornl_logo
176        logo = wx.Bitmap(image)       
177        self.bitmap_button_ornl.SetBitmapLabel(logo)
178
179        """
180        image = file_dir + "/images/sns_logo.png"
181        if os.path.isfile(config._sns_logo):
182            image = config._sns_logo
183        logo = wx.Bitmap(image)       
184        self.bitmap_button_sns.SetBitmapLabel(logo)
185       
186        image = file_dir + "/images/nsf_logo.png"
187        if os.path.isfile(config._nsf_logo):
188            image = config._nsf_logo
189        logo = wx.Bitmap(image)       
190        self.bitmap_button_nsf.SetBitmapLabel(logo)
191
192        image = file_dir + "/images/danse_logo.png"
193        if os.path.isfile(config._danse_logo):
194            image = config._danse_logo
195        logo = wx.Bitmap(image)
196        self.bitmap_button_danse.SetBitmapLabel(logo)
197        """
198        image = file_dir + "/images/utlogo.gif"
199        if os.path.isfile(config._inst_logo):
200            image = config._inst_logo
201        logo = wx.Bitmap(image)
202        self.bitmap_button_msu.SetBitmapLabel(logo)
203       
204        image = file_dir + "/images/isis_logo.png"
205        if os.path.isfile(config._isis_logo):
206            image = config._isis_logo
207        logo = wx.Bitmap(image)       
208        self.bitmap_button_isis.SetBitmapLabel(logo)
209
210        image = file_dir + "/images/ess_logo.png"
211        if os.path.isfile(config._ess_logo):
212            image = config._ess_logo
213        logo = wx.Bitmap(image)
214        self.bitmap_button_ess.SetBitmapLabel(logo)
215       
216        image = file_dir + "/images/ill_logo.png"
217        if os.path.isfile(config._ill_logo):
218            image = config._ill_logo
219        logo = wx.Bitmap(image)
220        self.bitmap_button_ill.SetBitmapLabel(logo)
221       
222        image = file_dir + "/images/ansto_logo.png"
223        if os.path.isfile(config._ansto_logo):
224            image = config._ansto_logo
225        logo = wx.Bitmap(image)
226        self.bitmap_button_ansto.SetBitmapLabel(logo)
227       
228        image = file_dir + "/images/tudelft_logo.png"
229        if os.path.isfile(config._tudelft_logo):
230            image = config._tudelft_logo
231        logo = wx.Bitmap(image)
232        self.bitmap_button_tudelft.SetBitmapLabel(logo)
233       
234        image = file_dir + "/images/dls_logo.png"
235        if os.path.isfile(config._dls_logo):
236            image = config._dls_logo
237        logo = wx.Bitmap(image)
238        self.bitmap_button_dls.SetBitmapLabel(logo)
239               
240        # resize dialog window to fit version number nicely
241        if wx.VERSION >= (2, 7, 2, 0):
242            size = [self.GetEffectiveMinSize()[0], self.GetSize()[1]]
243        else:
244            size = [self.GetBestFittingSize()[0], self.GetSize()[1]]
245        self.Fit()
246       
247    def __set_properties(self):
248        """
249        """
250        # begin wxGlade: DialogAbout.__set_properties
251        self.SetTitle("About")
252        self.SetSize((600, 595))
253        self.label_title.SetFont(wx.Font(26, wx.DEFAULT, wx.NORMAL,
254                                         wx.BOLD, 0, ""))
255        self.label_version.SetFont(wx.Font(26, wx.DEFAULT, wx.NORMAL,
256                                           wx.NORMAL, 0, ""))
257        self.hyperlink_paper.Enable(True)
258        self.bitmap_button_nist.SetSize(self.bitmap_button_nist.GetBestSize())
259        self.bitmap_button_umd.SetSize(self.bitmap_button_umd.GetBestSize())
260        self.bitmap_button_ornl.SetSize(self.bitmap_button_ornl.GetBestSize())
261        #self.bitmap_button_sns.SetSize(self.bitmap_button_sns.GetBestSize())
262        #self.bitmap_button_nsf.SetSize(self.bitmap_button_nsf.GetBestSize())
263        #self.bitmap_button_danse.SetSize(self.bitmap_button_danse.GetBestSize())
264        self.bitmap_button_msu.SetSize(self.bitmap_button_msu.GetBestSize())
265        self.bitmap_button_isis.SetSize(self.bitmap_button_isis.GetBestSize())
266        self.bitmap_button_ess.SetSize(self.bitmap_button_ess.GetBestSize())
267        self.bitmap_button_ill.SetSize(self.bitmap_button_ill.GetBestSize())
268        self.bitmap_button_ansto.SetSize(self.bitmap_button_ansto.GetBestSize())
269        self.bitmap_button_tudelft.SetSize(self.bitmap_button_tudelft.GetBestSize())
270        self.bitmap_button_dls.SetSize(self.bitmap_button_dls.GetBestSize())
271        # end wxGlade
272
273    def __do_layout(self):
274        """
275        """
276        # begin wxGlade: DialogAbout.__do_layout
277        sizer_main = wx.BoxSizer(wx.VERTICAL)
278        sizer_button = wx.BoxSizer(wx.HORIZONTAL)
279        sizer_logos = wx.BoxSizer(wx.HORIZONTAL)
280        sizer_header = wx.BoxSizer(wx.HORIZONTAL)
281        sizer_titles = wx.BoxSizer(wx.VERTICAL)
282        sizer_build = wx.BoxSizer(wx.HORIZONTAL)
283        sizer_title = wx.BoxSizer(wx.HORIZONTAL)
284        sizer_header.Add(self.bitmap_logo, 0, wx.EXPAND, 0)
285        sizer_title.Add(self.label_title, 0,
286                        wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10)
287        sizer_title.Add((20, 20), 0, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
288        sizer_title.Add(self.label_version, 0,
289                        wx.RIGHT|wx.ALIGN_BOTTOM|wx.ADJUST_MINSIZE, 10)
290        sizer_titles.Add(sizer_title, 0, wx.EXPAND, 0)
291        sizer_build.Add(self.label_build, 0,
292                        wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10)
293        sizer_build.Add(self.label_svnrevision, 0, wx.ADJUST_MINSIZE, 0)
294        sizer_titles.Add(sizer_build, 0, wx.TOP|wx.EXPAND, 5)
295        sizer_titles.Add(self.label_copyright, 0,
296                         wx.LEFT|wx.RIGHT|wx.TOP|wx.ADJUST_MINSIZE, 10)
297        sizer_titles.Add(self.label_author, 0,
298                         wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10)
299        sizer_titles.Add(self.hyperlink, 0, wx.LEFT|wx.RIGHT, 10)
300        sizer_titles.Add((20, 20), 0, wx.ADJUST_MINSIZE, 0)
301        sizer_titles.Add(self.hyperlink_license, 0, wx.LEFT|wx.RIGHT, 10)
302        sizer_titles.Add(self.hyperlink_paper, 0, wx.LEFT|wx.RIGHT, 10)
303        sizer_titles.Add((20, 20), 0, wx.ADJUST_MINSIZE, 0)
304        sizer_titles.Add(self.hyperlink_download, 0, wx.LEFT|wx.RIGHT, 10)
305        sizer_header.Add(sizer_titles, 0, wx.EXPAND, 0)
306        sizer_main.Add(sizer_header, 0, wx.BOTTOM|wx.EXPAND, 3)
307        sizer_main.Add(self.static_line_1, 0, wx.EXPAND, 0)
308        sizer_main.Add(self.label_acknowledgement, 0,
309                       wx.LEFT|wx.TOP|wx.BOTTOM|wx.ADJUST_MINSIZE, 7)
310        sizer_main.Add(self.static_line_2, 0, wx.EXPAND, 0)
311
312        sizer_logos.Add(self.bitmap_button_msu, 0, 
313                        wx.LEFT|wx.ADJUST_MINSIZE, 2)
314        #sizer_logos.Add(self.bitmap_button_danse, 0,
315        #                wx.LEFT|wx.ADJUST_MINSIZE, 2)
316        #sizer_logos.Add(self.bitmap_button_nsf, 0,
317        #                wx.LEFT|wx.ADJUST_MINSIZE, 2)
318        sizer_logos.Add(self.bitmap_button_umd, 0, 
319                        wx.LEFT|wx.ADJUST_MINSIZE, 2)
320        sizer_logos.Add(self.bitmap_button_nist, 0, 
321                        wx.LEFT|wx.ADJUST_MINSIZE, 2)
322        #sizer_logos.Add(self.bitmap_button_sns, 0,
323        #                wx.LEFT|wx.ADJUST_MINSIZE, 2)
324        sizer_logos.Add(self.bitmap_button_ornl, 0, 
325                        wx.LEFT|wx.ADJUST_MINSIZE, 2)
326        sizer_logos.Add(self.bitmap_button_isis, 0, 
327                        wx.LEFT|wx.ADJUST_MINSIZE, 2)
328        sizer_logos.Add(self.bitmap_button_ess, 0, 
329                        wx.LEFT|wx.ADJUST_MINSIZE, 2)
330        sizer_logos.Add(self.bitmap_button_ill, 0, 
331                        wx.LEFT|wx.ADJUST_MINSIZE, 2)
332        sizer_logos.Add(self.bitmap_button_ansto, 0, 
333                        wx.LEFT|wx.ADJUST_MINSIZE, 2)
334        sizer_logos.Add(self.bitmap_button_tudelft, 0, 
335                        wx.LEFT|wx.ADJUST_MINSIZE, 2)
336        sizer_logos.Add(self.bitmap_button_dls, 0, 
337                        wx.LEFT|wx.ADJUST_MINSIZE, 2)
338               
339        sizer_logos.Add((10, 50), 0, wx.ADJUST_MINSIZE, 0)
340        sizer_main.Add(sizer_logos, 0, wx.EXPAND, 0)
341        sizer_main.Add(self.static_line_3, 0, wx.EXPAND, 0)
342        sizer_button.Add((20, 40), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
343        sizer_button.Add(self.button_OK, 0, 
344                         wx.RIGHT|wx.ADJUST_MINSIZE|wx.CENTER, 10)
345        sizer_main.Add(sizer_button, 0, wx.EXPAND, 0)
346        self.SetAutoLayout(True)
347        self.SetSizer(sizer_main)
348        self.Layout()
349        self.Centre()
350        # end wxGlade
351
352    def onNistLogo(self, event): 
353        """
354        """
355        # wxGlade: DialogAbout.<event_handler>
356        launchBrowser(config._nist_url)
357        event.Skip()
358       
359    def onUmdLogo(self, event): 
360        """
361        """
362        # wxGlade: DialogAbout.<event_handler>
363        launchBrowser(config._umd_url)
364        event.Skip()
365       
366    def onOrnlLogo(self, event): 
367        """
368        """
369        # wxGlade: DialogAbout.<event_handler>
370        launchBrowser(config._ornl_url)
371        event.Skip()
372       
373    def onSnsLogo(self, event): 
374        """
375        """
376        # wxGlade: DialogAbout.<event_handler>
377        launchBrowser(config._sns_url)
378        event.Skip()
379               
380    def onNsfLogo(self, event): 
381        """
382        """
383        # wxGlade: DialogAbout.<event_handler>
384        launchBrowser(config._nsf_url)
385        event.Skip()
386
387    def onDanseLogo(self, event):
388        """
389        """
390        # wxGlade: DialogAbout.<event_handler>
391        launchBrowser(config._danse_url)
392        event.Skip()
393
394    def onUTLogo(self, event):
395        """
396        """ 
397        # wxGlade: DialogAbout.<event_handler>
398        launchBrowser(config._inst_url)
399        event.Skip()
400
401    def onIsisLogo(self, event): 
402        """
403        """
404        # wxGlade: DialogAbout.<event_handler>
405        launchBrowser(config._isis_url)
406        event.Skip()
407
408    def onEssLogo(self, event):
409        """
410        """
411        # wxGlade: DialogAbout.<event_handler>
412        launchBrowser(config._ess_url)
413        event.Skip()
414
415    def onIllLogo(self, event):
416        """
417        """ 
418        # wxGlade: DialogAbout.<event_handler>
419        launchBrowser(config._ill_url)
420        event.Skip()
421
422    def onAnstoLogo(self, event):
423        """
424        """ 
425        # wxGlade: DialogAbout.<event_handler>
426        launchBrowser(config._ansto_url)
427        event.Skip()
428
429    def onTudelftLogo(self, event):
430        """
431        """ 
432        # wxGlade: DialogAbout.<event_handler>
433        launchBrowser(config._tudelft_url)
434        event.Skip()
435
436    def onDlsLogo(self, event):
437        """
438        """ 
439        # wxGlade: DialogAbout.<event_handler>
440        launchBrowser(config._dls_url)
441        event.Skip()
442
443# end of class DialogAbout
444
445##### testing code ############################################################
446class MyApp(wx.App):
447    """
448    """
449    def OnInit(self):
450        """
451        """
452        wx.InitAllImageHandlers()
453        dialog = DialogAbout(None, -1, "")
454        self.SetTopWindow(dialog)
455        dialog.ShowModal()
456        dialog.Destroy()
457        return 1
458
459# end of class MyApp
460
461if __name__ == "__main__":
462    app = MyApp(0)
463    app.MainLoop()
464   
465##### end of testing code #####################################################   
Note: See TracBrowser for help on using the repository browser.