source: sasview/guiframe/aboutbox.py @ 43723aa

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.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 43723aa was 278cc25, checked in by Mathieu Doucet <doucetm@…>, 17 years ago

Allow adding base perspectives to an app (as opposed of only dynamically finding them out).
Modified plot label update

  • Property mode set to 100644
File size: 10.1 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    '''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
52class DialogAbout(wx.Dialog):
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        wx.Dialog.__init__(self, *args, **kwds)
64       
65        file_dir = os.path.dirname(__file__)
66       
67        # Mac doesn't display images with transparent background so well, keep it for Windows
68        image = file_dir+"/images/angles_flat.png"
69        if os.path.isfile(config._corner_image):
70            image = config._corner_image
71
72        if os.name == 'nt':
73            self.bitmap_logo = wx.StaticBitmap(self, -1, wx.Bitmap(image))
74        else:
75            self.bitmap_logo = wx.StaticBitmap(self, -1, wx.Bitmap(image))
76       
77        self.label_title = wx.StaticText(self, -1, config.__appname__)
78        self.label_version = wx.StaticText(self, -1, "")
79        self.label_build = wx.StaticText(self, -1, "Build:")
80        self.label_svnrevision = wx.StaticText(self, -1, "")
81        self.label_copyright = wx.StaticText(self, -1, config._copyright)
82        self.label_author = wx.StaticText(self, -1, "authors")
83        self.hyperlink = wx.lib.hyperlink.HyperLinkCtrl(self, -1, config._homepage, URL=config._homepage)
84        #self.hyperlink_license = wx.lib.hyperlink.HyperLinkCtrl(self, -1, "Comments? Bugs? Requests?", URL=config._paper)
85        self.hyperlink_license = wx.StaticText(self, -1, "Comments? Bugs? Requests?")
86        self.hyperlink_paper = wx.lib.hyperlink.HyperLinkCtrl(self, -1, "Send us a ticket", URL=config._license)
87        self.hyperlink_download = wx.lib.hyperlink.HyperLinkCtrl(self, -1, "Get the latest version", URL=config._download)
88        self.static_line_1 = wx.StaticLine(self, -1)
89        self.label_acknowledgement = wx.StaticText(self, -1, config._acknowledgement)
90        self.static_line_2 = wx.StaticLine(self, -1)
91        self.bitmap_button_nsf = wx.BitmapButton(self, -1, wx.NullBitmap)
92        self.bitmap_button_danse = wx.BitmapButton(self, -1, wx.NullBitmap)
93        self.bitmap_button_msu = wx.BitmapButton(self, -1, wx.NullBitmap)
94        self.static_line_3 = wx.StaticLine(self, -1)
95        self.button_OK = wx.Button(self, wx.ID_OK, "OK")
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        self.SetTitle("About")
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        sizer_button = wx.BoxSizer(wx.HORIZONTAL)
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        sizer_main.Add(self.static_line_3, 0, wx.EXPAND, 0)
202        sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
203        sizer_button.Add(self.button_OK, 0, wx.RIGHT|wx.ADJUST_MINSIZE, 10)
204        sizer_main.Add(sizer_button, 0, wx.EXPAND, 0)
205        self.SetAutoLayout(True)
206        self.SetSizer(sizer_main)
207        self.Layout()
208        self.Centre()
209        # end wxGlade
210
211    def onNsfLogo(self, event): # wxGlade: DialogAbout.<event_handler>
212        launchBrowser(config._nsf_url)
213        event.Skip()
214
215    def onDanseLogo(self, event): # wxGlade: DialogAbout.<event_handler>
216        launchBrowser(config._danse_url)
217        event.Skip()
218
219    def onUTLogo(self, event): # wxGlade: DialogAbout.<event_handler>
220        launchBrowser(config._inst_url)
221        event.Skip()
222
223# end of class DialogAbout
224
225##### testing code ############################################################
226class MyApp(wx.App):
227    def OnInit(self):
228        wx.InitAllImageHandlers()
229        dialog = DialogAbout(None, -1, "")
230        self.SetTopWindow(dialog)
231        dialog.ShowModal()
232        dialog.Destroy()
233        return 1
234
235# end of class MyApp
236
237if __name__ == "__main__":
238    app = MyApp(0)
239    app.MainLoop()
240   
241##### end of testing code #####################################################   
Note: See TracBrowser for help on using the repository browser.