forked from diffpy/diffpy.pdfgui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaboutdialog.py
More file actions
246 lines (211 loc) · 10 KB
/
aboutdialog.py
File metadata and controls
246 lines (211 loc) · 10 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
#!/usr/bin/env python
##############################################################################
#
# PDFgui by DANSE Diffraction group
# Simon J. L. Billinge
# (c) 2006 Trustees of the Michigan State University.
# (c) 2024 Trustees of the Columbia University in the City
# of New York
# All rights reserved.
#
# File coded by: Dmitriy Bryndin
#
# See AUTHORS.txt for a list of people who contributed.
# See LICENSE.txt for license information.
#
##############################################################################
import random
from datetime import datetime, timezone
import wx
import wx.lib.agw.hyperlink
from diffpy.pdfgui.gui.pdfguiglobals import iconpath
from diffpy.pdfgui.version import __version__
__date__ = datetime.now(timezone.utc).date().isoformat()
_acknowledgement = """\
This software was developed by the Billinge-group as part of the Distributed
Data Analysis of Neutron Scattering Experiments (DANSE) project funded by the US
National Science Foundation under grant DMR-0520547. Developments of PDFfit2
were funded by NSF grant DMR-0304391 in the Billinge-group, and with support
from Michigan State University and Columbia University. Any opinions, findings,
and conclusions or recommendations expressed in this material are those of the
author(s) and do not necessarily reflect the views of the respective funding
bodies.
If you use this program to do productive scientific research that leads to
publication, we ask that you acknowledge use of the program by citing the
following paper in your publication:
C. L. Farrow, P. Juhas, J. W. Liu, D. Bryndin, E. S. Bozin,
J. Bloch, Th. Proffen and S. J. L. Billinge, PDFfit2 and PDFgui:
computer programs for studying nanostructure in crystals,
J. Phys.: Condens. Matter 19, 335219 (2007)."""
_copyright = f"(c) 2005-{__date__[-4:]},"
_homepage = "https://www.diffpy.org"
# authors list is shuffled randomly every time
_authors = [
"S. J. L. Billinge",
"E. S. Bozin",
"D. Bryndin",
"C. L. Farrow",
"P. Juhas",
"J. W. Liu",
]
_paper = "https://stacks.iop.org/0953-8984/19/335219"
_license = ""
def launchBrowser(url):
"""Launches browser and opens specified url.
In some cases may require BROWSER environment variable to be set up.
@param url: URL to open
"""
import webbrowser
webbrowser.open(url)
class DialogAbout(wx.Dialog):
"""The "About" Dialog.
Shows product name, current version, authors, and link to the
product page. Current version is taken from version.py
"""
def __init__(self, *args, **kwds):
# begin wxGlade: DialogAbout.__init__
kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_DIALOG_STYLE
wx.Dialog.__init__(self, *args, **kwds)
self.SetSize((600, 595))
self.bitmap_logo = wx.StaticBitmap(self, wx.ID_ANY, wx.Bitmap(iconpath("logo.png")))
self.label_title = wx.StaticText(self, wx.ID_ANY, "PDFgui")
self.label_version = wx.StaticText(self, wx.ID_ANY, "")
self.label_build = wx.StaticText(self, wx.ID_ANY, "Build:")
self.label_svnrevision = wx.StaticText(self, wx.ID_ANY, "")
self.label_copyright = wx.StaticText(self, wx.ID_ANY, "")
self.label_author = wx.StaticText(self, wx.ID_ANY, "author")
self.hyperlink = wx.lib.agw.hyperlink.HyperLinkCtrl(self, wx.ID_ANY, _homepage, URL=_homepage)
self.hyperlink_license = wx.lib.agw.hyperlink.HyperLinkCtrl(self, wx.ID_ANY, _license, URL=_license)
self.static_line_1 = wx.StaticLine(self, wx.ID_ANY)
self.label_acknowledgement = wx.StaticText(self, wx.ID_ANY, "")
self.hyperlink_paper = wx.lib.agw.hyperlink.HyperLinkCtrl(self, wx.ID_ANY, _paper, URL=_paper)
self.static_line_2 = wx.StaticLine(self, wx.ID_ANY)
self.bitmap_button_nsf = wx.BitmapButton(self, wx.ID_ANY, wx.NullBitmap, style=wx.BU_AUTODRAW)
self.bitmap_button_danse = wx.BitmapButton(self, wx.ID_ANY, wx.NullBitmap, style=wx.BU_AUTODRAW)
self.bitmap_button_msu = wx.BitmapButton(self, wx.ID_ANY, wx.NullBitmap, style=wx.BU_AUTODRAW)
self.bitmap_button_columbia = wx.BitmapButton(self, wx.ID_ANY, wx.NullBitmap, style=wx.BU_AUTODRAW)
self.static_line_3 = wx.StaticLine(self, wx.ID_ANY)
self.button_OK = wx.Button(self, wx.ID_OK, "OK")
self.__set_properties()
self.__do_layout()
self.Bind(wx.EVT_BUTTON, self.onNsfLogo, self.bitmap_button_nsf)
self.Bind(wx.EVT_BUTTON, self.onDanseLogo, self.bitmap_button_danse)
self.Bind(wx.EVT_BUTTON, self.onMsuLogo, self.bitmap_button_msu)
self.Bind(wx.EVT_BUTTON, self.onColumbiaLogo, self.bitmap_button_columbia)
# end wxGlade
# randomly shuffle authors' names
random.shuffle(_authors)
strLabel = ", ".join(_authors)
self.label_author.SetLabel(strLabel)
# setup acknowledgement and copyright text labels
self.label_acknowledgement.SetLabel(_acknowledgement)
self.label_copyright.SetLabel(_copyright)
# display version and svn revision numbers
verwords = __version__.split(".post", 1)
version = verwords[0]
revision = "0" if len(verwords) == 1 else verwords[1]
self.label_version.SetLabel(version)
self.label_svnrevision.SetLabel(revision)
# set bitmaps for logo buttons
logo = wx.Bitmap(iconpath("nsf-logo.png"))
self.bitmap_button_nsf.SetBitmapLabel(logo)
logo = wx.Bitmap(iconpath("danse-logo.png"))
self.bitmap_button_danse.SetBitmapLabel(logo)
logo = wx.Bitmap(iconpath("msu-logo.png"))
self.bitmap_button_msu.SetBitmapLabel(logo)
logo = wx.Bitmap(iconpath("columbia-logo.png"))
self.bitmap_button_columbia.SetBitmapLabel(logo)
# resize dialog window to fit version number nicely
self.Fit()
return
def __set_properties(self):
# begin wxGlade: DialogAbout.__set_properties
self.SetTitle("About")
self.SetSize((600, 595))
self.label_title.SetFont(
wx.Font(
26,
wx.FONTFAMILY_DEFAULT,
wx.FONTSTYLE_NORMAL,
wx.FONTWEIGHT_BOLD,
0,
"",
)
)
self.label_version.SetFont(
wx.Font(
26,
wx.FONTFAMILY_DEFAULT,
wx.FONTSTYLE_NORMAL,
wx.FONTWEIGHT_NORMAL,
0,
"",
)
)
self.hyperlink_license.Enable(False)
self.hyperlink_license.Hide()
self.bitmap_button_nsf.SetSize(self.bitmap_button_nsf.GetBestSize())
self.bitmap_button_danse.SetSize(self.bitmap_button_danse.GetBestSize())
self.bitmap_button_msu.SetSize(self.bitmap_button_msu.GetBestSize())
self.bitmap_button_columbia.SetSize(self.bitmap_button_columbia.GetBestSize())
# end wxGlade
def __do_layout(self):
# begin wxGlade: DialogAbout.__do_layout
sizer_main = wx.BoxSizer(wx.VERTICAL)
sizer_button = wx.BoxSizer(wx.HORIZONTAL)
sizer_logos = wx.BoxSizer(wx.HORIZONTAL)
sizer_header = wx.BoxSizer(wx.HORIZONTAL)
sizer_titles = wx.BoxSizer(wx.VERTICAL)
sizer_build = wx.BoxSizer(wx.HORIZONTAL)
sizer_title = wx.BoxSizer(wx.HORIZONTAL)
sizer_header.Add(self.bitmap_logo, 0, wx.EXPAND, 0)
sizer_title.Add(self.label_title, 0, wx.EXPAND | wx.LEFT | wx.TOP, 10)
sizer_title.Add((20, 20), 0, wx.EXPAND, 0)
sizer_title.Add(self.label_version, 0, wx.ALIGN_BOTTOM | wx.RIGHT, 10)
sizer_titles.Add(sizer_title, 0, wx.EXPAND, 0)
sizer_build.Add(self.label_build, 0, wx.LEFT | wx.RIGHT, 10)
sizer_build.Add(self.label_svnrevision, 0, 0, 0)
sizer_titles.Add(sizer_build, 0, wx.EXPAND | wx.TOP, 5)
sizer_titles.Add(self.label_copyright, 0, wx.LEFT | wx.RIGHT | wx.TOP, 10)
sizer_titles.Add(self.label_author, 0, wx.LEFT | wx.RIGHT, 10)
sizer_titles.Add(self.hyperlink, 0, wx.LEFT | wx.RIGHT, 10)
sizer_titles.Add((20, 20), 0, 0, 0)
sizer_titles.Add(self.hyperlink_license, 0, wx.LEFT | wx.RIGHT, 10)
sizer_header.Add(sizer_titles, 0, wx.EXPAND, 0)
sizer_main.Add(sizer_header, 0, wx.BOTTOM | wx.EXPAND, 3)
sizer_main.Add(self.static_line_1, 0, wx.EXPAND, 0)
sizer_main.Add(self.label_acknowledgement, 0, wx.BOTTOM | wx.LEFT | wx.TOP, 7)
sizer_main.Add(self.hyperlink_paper, 0, wx.BOTTOM | wx.LEFT | wx.TOP, 7)
sizer_main.Add(self.static_line_2, 0, wx.EXPAND, 0)
sizer_logos.Add(self.bitmap_button_nsf, 0, wx.LEFT, 2)
sizer_logos.Add(self.bitmap_button_danse, 0, wx.LEFT, 2)
sizer_logos.Add(self.bitmap_button_msu, 0, wx.LEFT, 2)
sizer_logos.Add(self.bitmap_button_columbia, 0, wx.LEFT, 2)
sizer_logos.Add((50, 50), 0, 0, 0)
sizer_main.Add(sizer_logos, 0, wx.EXPAND, 0)
sizer_main.Add(self.static_line_3, 0, wx.EXPAND, 0)
sizer_button.Add((20, 20), 1, wx.EXPAND, 0)
sizer_button.Add(self.button_OK, 0, wx.RIGHT, 10)
sizer_main.Add(sizer_button, 0, wx.EXPAND, 0)
self.SetSizer(sizer_main)
self.Layout()
self.Centre()
# end wxGlade
def onNsfLogo(self, event): # wxGlade: DialogAbout.<event_handler>
launchBrowser("https://www.nsf.gov")
event.Skip()
def onDanseLogo(self, event): # wxGlade: DialogAbout.<event_handler>
launchBrowser("https://www.its.caltech.edu/~matsci/btf/DANSE_web_page.html")
event.Skip()
def onMsuLogo(self, event): # wxGlade: DialogAbout.<event_handler>
launchBrowser("https://www.msu.edu")
event.Skip()
def onColumbiaLogo(self, event): # wxGlade: DialogAbout.<event_handler>
launchBrowser("https://www.columbia.edu")
event.Skip()
# end of class DialogAbout
# testing code ###########################################################
if __name__ == "__main__":
app = wx.App()
dialog = DialogAbout(None, -1, "")
dialog.ShowModal()