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

magnetic_scattrelease-4.2.2ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249unittest-saveload
Last change on this file since 9fb4572 was 1b4cb41, checked in by smk78, 6 years ago

Added BAM to About box

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