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

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.1.1release-4.1.2release-4.2.2ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since e0f28e6 was e0f28e6, checked in by smk78, 8 years ago

Updated About box text and images. Changed SNS image to ORNL image (more
inclusive) and added ANSTO image.

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