source: sasview/guitools/aboutbox.py @ 672c44da

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 672c44da was 4e290cd, checked in by Mathieu Doucet <doucetm@…>, 17 years ago

Fixed error bar color and added about box

  • Property mode set to 100644
File size: 9.2 KB
RevLine 
[4e290cd]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
26import config
27
28def launchBrowser(url):
29    '''Launches browser and opens specified url
30   
31    In some cases may require BROWSER environment variable to be set up.
32   
33    @param url: URL to open
34    '''
35    import webbrowser
36    webbrowser.open(url)
37
38
39class DialogAbout(wx.Dialog):
40    '''"About" Dialog
41   
42    Shows product name, current version, authors, and link to the product page.
43    Current version is taken from version.py
44    '''
45   
46    def __init__(self, *args, **kwds):
47
48        # begin wxGlade: DialogAbout.__init__
49        kwds["style"] = wx.DEFAULT_DIALOG_STYLE
50        wx.Dialog.__init__(self, *args, **kwds)
51       
52        # Mac doesn't display images with transparent background so well, keep it for Windows
53        if os.name == 'nt':
54            self.bitmap_logo = wx.StaticBitmap(self, -1, wx.Bitmap(os.path.join("images",config._corner_image)))
55        else:
56            self.bitmap_logo = wx.StaticBitmap(self, -1, wx.Bitmap(os.path.join("images",config._corner_image)))
57       
58        self.label_title = wx.StaticText(self, -1, config.__appname__)
59        self.label_version = wx.StaticText(self, -1, "")
60        self.label_build = wx.StaticText(self, -1, "Build:")
61        self.label_svnrevision = wx.StaticText(self, -1, "")
62        self.label_copyright = wx.StaticText(self, -1, config._copyright)
63        self.label_author = wx.StaticText(self, -1, "authors")
64        self.hyperlink = wx.lib.hyperlink.HyperLinkCtrl(self, -1, config._homepage, URL=config._homepage)
65        #self.hyperlink_license = wx.lib.hyperlink.HyperLinkCtrl(self, -1, "Comments? Bugs? Requests?", URL=config._paper)
66        self.hyperlink_license = wx.StaticText(self, -1, "Comments? Bugs? Requests?")
67        self.hyperlink_paper = wx.lib.hyperlink.HyperLinkCtrl(self, -1, "Send us a ticket", URL=config._license)
68        self.hyperlink_download = wx.lib.hyperlink.HyperLinkCtrl(self, -1, "Get the latest version", URL=config._download)
69        self.static_line_1 = wx.StaticLine(self, -1)
70        self.label_acknowledgement = wx.StaticText(self, -1, config._acknowledgement)
71        self.static_line_2 = wx.StaticLine(self, -1)
72        self.bitmap_button_nsf = wx.BitmapButton(self, -1, wx.NullBitmap)
73        self.bitmap_button_danse = wx.BitmapButton(self, -1, wx.NullBitmap)
74        self.bitmap_button_msu = wx.BitmapButton(self, -1, wx.NullBitmap)
75        self.static_line_3 = wx.StaticLine(self, -1)
76        self.button_OK = wx.Button(self, wx.ID_OK, "OK")
77
78        self.__set_properties()
79        self.__do_layout()
80
81        self.Bind(wx.EVT_BUTTON, self.onNsfLogo, self.bitmap_button_nsf)
82        self.Bind(wx.EVT_BUTTON, self.onDanseLogo, self.bitmap_button_danse)
83        self.Bind(wx.EVT_BUTTON, self.onUTLogo, self.bitmap_button_msu)
84        # end wxGlade
85       
86        # fill in acknowledgements
87#       self.text_ctrl_acknowledgement.SetValue(__acknowledgement__)
88
89        # randomly shuffle authors' names
90        random.shuffle(config._authors)
91        strLabel = ", ".join(config._authors)
92       
93        # display version and svn revison numbers
94        verwords = config.__version__.split('.')
95        version = '.'.join(verwords[:-1])
96        revision = verwords[-1]
97       
98        self.label_author.SetLabel(strLabel)
99        self.label_version.SetLabel(version)
100        self.label_svnrevision.SetLabel(config.__version__)
101       
102        # set bitmaps for logo buttons
103        logo = wx.Bitmap(os.path.join("images",config._nsf_logo))
104        self.bitmap_button_nsf.SetBitmapLabel(logo)
105        logo = wx.Bitmap(os.path.join("images",config._danse_logo))
106        self.bitmap_button_danse.SetBitmapLabel(logo)
107        logo = wx.Bitmap(os.path.join("images",config._inst_logo))
108        self.bitmap_button_msu.SetBitmapLabel(logo)
109       
110        # resize dialog window to fit version number nicely
111        if wx.VERSION >= (2,7,2,0):
112            size = [self.GetEffectiveMinSize()[0], self.GetSize()[1]]
113        else:
114            size = [self.GetBestFittingSize()[0], self.GetSize()[1]]
115
116        self.Fit()
117#        self.SetSize(size)
118#       self.FitInside()
119       
120
121    def __set_properties(self):
122        # begin wxGlade: DialogAbout.__set_properties
123        self.SetTitle("About")
124        self.SetSize((600, 595))
125        self.label_title.SetFont(wx.Font(26, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
126        self.label_version.SetFont(wx.Font(26, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, ""))
127        #self.hyperlink_license.Enable(False)
128        #self.hyperlink_license.Hide()
129        self.hyperlink_paper.Enable(True)
130        #self.hyperlink_paper.Hide()
131        self.bitmap_button_nsf.SetSize(self.bitmap_button_nsf.GetBestSize())
132        self.bitmap_button_danse.SetSize(self.bitmap_button_danse.GetBestSize())
133        self.bitmap_button_msu.SetSize(self.bitmap_button_msu.GetBestSize())
134        # end wxGlade
135
136    def __do_layout(self):
137        # begin wxGlade: DialogAbout.__do_layout
138        sizer_main = wx.BoxSizer(wx.VERTICAL)
139        sizer_button = wx.BoxSizer(wx.HORIZONTAL)
140        sizer_logos = wx.BoxSizer(wx.HORIZONTAL)
141        sizer_header = wx.BoxSizer(wx.HORIZONTAL)
142        sizer_titles = wx.BoxSizer(wx.VERTICAL)
143        sizer_build = wx.BoxSizer(wx.HORIZONTAL)
144        sizer_title = wx.BoxSizer(wx.HORIZONTAL)
145        sizer_header.Add(self.bitmap_logo, 0, wx.EXPAND, 0)
146        sizer_title.Add(self.label_title, 0, wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10)
147        sizer_title.Add((20, 20), 0, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
148        sizer_title.Add(self.label_version, 0, wx.RIGHT|wx.ALIGN_BOTTOM|wx.ADJUST_MINSIZE, 10)
149        sizer_titles.Add(sizer_title, 0, wx.EXPAND, 0)
150        sizer_build.Add(self.label_build, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10)
151        sizer_build.Add(self.label_svnrevision, 0, wx.ADJUST_MINSIZE, 0)
152        sizer_titles.Add(sizer_build, 0, wx.TOP|wx.EXPAND, 5)
153        sizer_titles.Add(self.label_copyright, 0, wx.LEFT|wx.RIGHT|wx.TOP|wx.ADJUST_MINSIZE, 10)
154        sizer_titles.Add(self.label_author, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10)
155        sizer_titles.Add(self.hyperlink, 0, wx.LEFT|wx.RIGHT, 10)
156        sizer_titles.Add((20, 20), 0, wx.ADJUST_MINSIZE, 0)
157        sizer_titles.Add(self.hyperlink_license, 0, wx.LEFT|wx.RIGHT, 10)
158        sizer_titles.Add(self.hyperlink_paper, 0, wx.LEFT|wx.RIGHT, 10)
159        sizer_titles.Add((20, 20), 0, wx.ADJUST_MINSIZE, 0)
160        sizer_titles.Add(self.hyperlink_download, 0, wx.LEFT|wx.RIGHT, 10)
161        sizer_header.Add(sizer_titles, 0, wx.EXPAND, 0)
162        sizer_main.Add(sizer_header, 0, wx.BOTTOM|wx.EXPAND, 3)
163        sizer_main.Add(self.static_line_1, 0, wx.EXPAND, 0)
164        sizer_main.Add(self.label_acknowledgement, 0, wx.LEFT|wx.TOP|wx.BOTTOM|wx.ADJUST_MINSIZE, 7)
165        sizer_main.Add(self.static_line_2, 0, wx.EXPAND, 0)
166        sizer_logos.Add(self.bitmap_button_nsf, 0, wx.LEFT|wx.ADJUST_MINSIZE, 2)
167        sizer_logos.Add(self.bitmap_button_danse, 0, wx.LEFT|wx.ADJUST_MINSIZE, 2)
168        sizer_logos.Add(self.bitmap_button_msu, 0, wx.LEFT|wx.ADJUST_MINSIZE, 2)
169        sizer_logos.Add((50, 50), 0, wx.ADJUST_MINSIZE, 0)
170        sizer_main.Add(sizer_logos, 0, wx.EXPAND, 0)
171        sizer_main.Add(self.static_line_3, 0, wx.EXPAND, 0)
172        sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
173        sizer_button.Add(self.button_OK, 0, wx.RIGHT|wx.ADJUST_MINSIZE, 10)
174        sizer_main.Add(sizer_button, 0, wx.EXPAND, 0)
175        self.SetAutoLayout(True)
176        self.SetSizer(sizer_main)
177        self.Layout()
178        self.Centre()
179        # end wxGlade
180
181    def onNsfLogo(self, event): # wxGlade: DialogAbout.<event_handler>
182        launchBrowser(config._nsf_url)
183        event.Skip()
184
185    def onDanseLogo(self, event): # wxGlade: DialogAbout.<event_handler>
186        launchBrowser(config._danse_url)
187        event.Skip()
188
189    def onUTLogo(self, event): # wxGlade: DialogAbout.<event_handler>
190        launchBrowser(config._inst_url)
191        event.Skip()
192
193# end of class DialogAbout
194
195##### testing code ############################################################
196class MyApp(wx.App):
197    def OnInit(self):
198        wx.InitAllImageHandlers()
199        dialog = DialogAbout(None, -1, "")
200        self.SetTopWindow(dialog)
201        dialog.ShowModal()
202        dialog.Destroy()
203        return 1
204
205# end of class MyApp
206
207if __name__ == "__main__":
208    app = MyApp(0)
209    app.MainLoop()
210   
211##### end of testing code #####################################################   
Note: See TracBrowser for help on using the repository browser.