source: sasview/guiframe/aboutbox.py @ 84a0e1f

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 84a0e1f was 2bd9927, checked in by Gervaise Alina <gervyh@…>, 16 years ago

move welcome panel

  • 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       
70        if os.path.isfile(config._corner_image):
71            image = config._corner_image
72
73        if os.name == 'nt':
74            self.bitmap_logo = wx.StaticBitmap(self, -1, wx.Bitmap(image))
75        else:
76            self.bitmap_logo = wx.StaticBitmap(self, -1, wx.Bitmap(image))
77       
78        self.label_title = wx.StaticText(self, -1, config.__appname__)
79        self.label_version = wx.StaticText(self, -1, "")
80        self.label_build = wx.StaticText(self, -1, "Build:")
81        self.label_svnrevision = wx.StaticText(self, -1, "")
82        self.label_copyright = wx.StaticText(self, -1, config._copyright)
83        self.label_author = wx.StaticText(self, -1, "authors")
84        self.hyperlink = wx.lib.hyperlink.HyperLinkCtrl(self, -1, config._homepage, URL=config._homepage)
85        #self.hyperlink_license = wx.lib.hyperlink.HyperLinkCtrl(self, -1, "Comments? Bugs? Requests?", URL=config._paper)
86        self.hyperlink_license = wx.StaticText(self, -1, "Comments? Bugs? Requests?")
87        self.hyperlink_paper = wx.lib.hyperlink.HyperLinkCtrl(self, -1, "Send us a ticket", URL=config._license)
88        self.hyperlink_download = wx.lib.hyperlink.HyperLinkCtrl(self, -1, "Get the latest version", URL=config._download)
89        self.static_line_1 = wx.StaticLine(self, -1)
90        self.label_acknowledgement = wx.StaticText(self, -1, config._acknowledgement)
91        self.static_line_2 = wx.StaticLine(self, -1)
92        self.bitmap_button_nsf = wx.BitmapButton(self, -1, wx.NullBitmap)
93        self.bitmap_button_danse = wx.BitmapButton(self, -1, wx.NullBitmap)
94        self.bitmap_button_msu = wx.BitmapButton(self, -1, wx.NullBitmap)
95        self.static_line_3 = wx.StaticLine(self, -1)
96        self.button_OK = wx.Button(self, wx.ID_OK, "OK")
97
98        self.__set_properties()
99        self.__do_layout()
100
101        self.Bind(wx.EVT_BUTTON, self.onNsfLogo, self.bitmap_button_nsf)
102        self.Bind(wx.EVT_BUTTON, self.onDanseLogo, self.bitmap_button_danse)
103        self.Bind(wx.EVT_BUTTON, self.onUTLogo, self.bitmap_button_msu)
104        # end wxGlade
105       
106        # fill in acknowledgements
107#       self.text_ctrl_acknowledgement.SetValue(__acknowledgement__)
108
109        # randomly shuffle authors' names
110        random.shuffle(config._authors)
111        strLabel = ", ".join(config._authors)
112       
113        # display version and svn revison numbers
114        verwords = config.__version__.split('.')
115        version = '.'.join(verwords[:-1])
116        revision = verwords[-1]
117       
118        self.label_author.SetLabel(strLabel)
119        self.label_version.SetLabel(version)
120        self.label_svnrevision.SetLabel(config.__version__)
121       
122        # set bitmaps for logo buttons
123        image = file_dir+"/images/nsf_logo.png"
124        if os.path.isfile(config._nsf_logo):
125            image = config._nsf_logo
126        logo = wx.Bitmap(image)       
127        self.bitmap_button_nsf.SetBitmapLabel(logo)
128
129        image = file_dir+"/images/danse_logo.png"
130        if os.path.isfile(config._danse_logo):
131            image = config._danse_logo
132        logo = wx.Bitmap(image)
133        self.bitmap_button_danse.SetBitmapLabel(logo)
134       
135        image = file_dir+"/images/utlogo.gif"
136        if os.path.isfile(config._inst_logo):
137            image = config._inst_logo
138        logo = wx.Bitmap(image)
139        self.bitmap_button_msu.SetBitmapLabel(logo)
140       
141        # resize dialog window to fit version number nicely
142        if wx.VERSION >= (2,7,2,0):
143            size = [self.GetEffectiveMinSize()[0], self.GetSize()[1]]
144        else:
145            size = [self.GetBestFittingSize()[0], self.GetSize()[1]]
146
147        self.Fit()
148#        self.SetSize(size)
149#       self.FitInside()
150       
151
152    def __set_properties(self):
153        # begin wxGlade: DialogAbout.__set_properties
154        self.SetTitle("About")
155        self.SetSize((600, 595))
156        self.label_title.SetFont(wx.Font(26, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
157        self.label_version.SetFont(wx.Font(26, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, ""))
158        #self.hyperlink_license.Enable(False)
159        #self.hyperlink_license.Hide()
160        self.hyperlink_paper.Enable(True)
161        #self.hyperlink_paper.Hide()
162        self.bitmap_button_nsf.SetSize(self.bitmap_button_nsf.GetBestSize())
163        self.bitmap_button_danse.SetSize(self.bitmap_button_danse.GetBestSize())
164        self.bitmap_button_msu.SetSize(self.bitmap_button_msu.GetBestSize())
165        # end wxGlade
166
167    def __do_layout(self):
168        # begin wxGlade: DialogAbout.__do_layout
169        sizer_main = wx.BoxSizer(wx.VERTICAL)
170        sizer_button = wx.BoxSizer(wx.HORIZONTAL)
171        sizer_logos = wx.BoxSizer(wx.HORIZONTAL)
172        sizer_header = wx.BoxSizer(wx.HORIZONTAL)
173        sizer_titles = wx.BoxSizer(wx.VERTICAL)
174        sizer_build = wx.BoxSizer(wx.HORIZONTAL)
175        sizer_title = wx.BoxSizer(wx.HORIZONTAL)
176        sizer_header.Add(self.bitmap_logo, 0, wx.EXPAND, 0)
177        sizer_title.Add(self.label_title, 0, wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10)
178        sizer_title.Add((20, 20), 0, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
179        sizer_title.Add(self.label_version, 0, wx.RIGHT|wx.ALIGN_BOTTOM|wx.ADJUST_MINSIZE, 10)
180        sizer_titles.Add(sizer_title, 0, wx.EXPAND, 0)
181        sizer_build.Add(self.label_build, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10)
182        sizer_build.Add(self.label_svnrevision, 0, wx.ADJUST_MINSIZE, 0)
183        sizer_titles.Add(sizer_build, 0, wx.TOP|wx.EXPAND, 5)
184        sizer_titles.Add(self.label_copyright, 0, wx.LEFT|wx.RIGHT|wx.TOP|wx.ADJUST_MINSIZE, 10)
185        sizer_titles.Add(self.label_author, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10)
186        sizer_titles.Add(self.hyperlink, 0, wx.LEFT|wx.RIGHT, 10)
187        sizer_titles.Add((20, 20), 0, wx.ADJUST_MINSIZE, 0)
188        sizer_titles.Add(self.hyperlink_license, 0, wx.LEFT|wx.RIGHT, 10)
189        sizer_titles.Add(self.hyperlink_paper, 0, wx.LEFT|wx.RIGHT, 10)
190        sizer_titles.Add((20, 20), 0, wx.ADJUST_MINSIZE, 0)
191        sizer_titles.Add(self.hyperlink_download, 0, wx.LEFT|wx.RIGHT, 10)
192        sizer_header.Add(sizer_titles, 0, wx.EXPAND, 0)
193        sizer_main.Add(sizer_header, 0, wx.BOTTOM|wx.EXPAND, 3)
194        sizer_main.Add(self.static_line_1, 0, wx.EXPAND, 0)
195        sizer_main.Add(self.label_acknowledgement, 0, wx.LEFT|wx.TOP|wx.BOTTOM|wx.ADJUST_MINSIZE, 7)
196        sizer_main.Add(self.static_line_2, 0, wx.EXPAND, 0)
197        sizer_logos.Add(self.bitmap_button_nsf, 0, wx.LEFT|wx.ADJUST_MINSIZE, 2)
198        sizer_logos.Add(self.bitmap_button_danse, 0, wx.LEFT|wx.ADJUST_MINSIZE, 2)
199        sizer_logos.Add(self.bitmap_button_msu, 0, wx.LEFT|wx.ADJUST_MINSIZE, 2)
200        sizer_logos.Add((50, 50), 0, wx.ADJUST_MINSIZE, 0)
201        sizer_main.Add(sizer_logos, 0, wx.EXPAND, 0)
202        sizer_main.Add(self.static_line_3, 0, wx.EXPAND, 0)
203        sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
204        sizer_button.Add(self.button_OK, 0, wx.RIGHT|wx.ADJUST_MINSIZE, 10)
205        sizer_main.Add(sizer_button, 0, wx.EXPAND, 0)
206        self.SetAutoLayout(True)
207        self.SetSizer(sizer_main)
208        self.Layout()
209        self.Centre()
210        # end wxGlade
211
212    def onNsfLogo(self, event): # wxGlade: DialogAbout.<event_handler>
213        launchBrowser(config._nsf_url)
214        event.Skip()
215
216    def onDanseLogo(self, event): # wxGlade: DialogAbout.<event_handler>
217        launchBrowser(config._danse_url)
218        event.Skip()
219
220    def onUTLogo(self, event): # wxGlade: DialogAbout.<event_handler>
221        launchBrowser(config._inst_url)
222        event.Skip()
223
224# end of class DialogAbout
225
226##### testing code ############################################################
227class MyApp(wx.App):
228    def OnInit(self):
229        wx.InitAllImageHandlers()
230        dialog = DialogAbout(None, -1, "")
231        self.SetTopWindow(dialog)
232        dialog.ShowModal()
233        dialog.Destroy()
234        return 1
235
236# end of class MyApp
237
238if __name__ == "__main__":
239    app = MyApp(0)
240    app.MainLoop()
241   
242##### end of testing code #####################################################   
Note: See TracBrowser for help on using the repository browser.