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

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalcmagnetic_scattrelease-4.2.2ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since efe730d was efe730d, checked in by Paul Kienzle <pkienzle@…>, 8 years ago

move sasview to src/sas/sasview and refactor bundled apps for easier debugging

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