/
about.py
285 lines (252 loc) · 10.5 KB
/
about.py
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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
# -*- coding: utf-8 -*-
#
# Copyright © Spyder Project Contributors
# Licensed under the terms of the MIT License
# (see spyder/__init__.py for details)
"""Module serving the "About Spyder" function"""
# Standard library imports
import sys
# Third party imports
from qtpy.QtCore import Qt
from qtpy.QtGui import QPixmap
from qtpy.QtWidgets import (QApplication, QDialog, QDialogButtonBox,
QHBoxLayout, QVBoxLayout, QLabel, QPushButton,
QScrollArea, QTabWidget)
# Local imports
from spyder import (
__project_url__ as project_url,
__forum_url__ as forum_url,
__trouble_url__ as trouble_url,
__website_url__ as website_url,
get_versions, get_versions_text
)
from spyder.config.base import _
from spyder.utils.icon_manager import ima
from spyder.utils.image_path_manager import get_image_path
from spyder.utils.palette import QStylePalette
from spyder.utils.stylesheet import APP_STYLESHEET, DialogStyle
class AboutDialog(QDialog):
def __init__(self, parent):
"""Create About Spyder dialog with general information."""
QDialog.__init__(self, parent)
self.setWindowFlags(
self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
versions = get_versions()
# Show Git revision for development version
revlink = ''
if versions['revision']:
rev = versions['revision']
revlink = ("<a href='https://github.com/spyder-ide/spyder/"
"commit/%s'>%s</a>" % (rev, rev))
# Get current font properties
font = self.font()
font_family = font.family()
buttons_padding = DialogStyle.ButtonsPadding
buttons_font_size = DialogStyle.ButtonsFontSize
font_size = DialogStyle.ContentFontSize
dialog_background_color = QStylePalette.COLOR_BACKGROUND_2
twitter_url = "https://twitter.com/Spyder_IDE",
facebook_url = "https://www.facebook.com/SpyderIDE",
youtube_url = "https://www.youtube.com/Spyder-IDE",
instagram_url = "https://www.instagram.com/spyderide/",
self.label_overview = QLabel(
f"""
<div style='font-family: "{font_family}";
font-size: {font_size};
font-weight: normal;
'>
<br>
<p>
<b> Spyder IDE</b>
<br> <br>
The Scientific Python Development Environment |
<a href="{website_url}">Spyder-IDE.org</a>
<br>
<p>
Python {versions['python']} {versions['bitness']}-bit |
Qt {versions['qt']} |
{versions['qt_api']} {versions['qt_api_ver']} |
{versions['system']} {versions['release']}
</p>
<br> <br>
<a href="{project_url}">GitHub</a> | <a href="{twitter_url}">
Twitter</a> |
<a href="{facebook_url}">Facebook</a> | <a href="{youtube_url}">
YouTube</a> |
<a href="{instagram_url}">Instagram</a>
</div>""")
self.label_community = QLabel(
f"""
<div style='font-family: "{font_family}";
font-size: {font_size};
font-weight: normal;
'>
<br>
<p>
Created by Pierre Raybaut; current maintainer is Carlos Cordoba.
Developed by the
<a href="{project_url}/graphs/contributors">international
Spyder community</a>. Many thanks to all the Spyder beta testers
and dedicated users.
</p>
<p>For help with Spyder errors and crashes, please read our
<a href="{trouble_url}">Troubleshooting Guide</a>, and for bug
reports and feature requests, visit our
<a href="{project_url}">Github site</a>. For project discussion,
see our <a href="{forum_url}">Google Group</a>.
</p>
<p>
This project is part of a larger effort to promote and
facilitate the use of Python for scientific and engineering
software development.
The popular Python distributions
<a href="https://www.anaconda.com/download/">Anaconda</a> and
<a href="https://winpython.github.io/">WinPython</a>
also contribute to this plan.
</p>
</div>""")
self.label_legal = QLabel(
f"""
<div style='font-family: "{font_family}";
font-size: {font_size};
font-weight: normal;
'>
<br>
<p>
Copyright © 2009-2020 Spyder Project Contributors and
<a href="{project_url}/blob/master/AUTHORS.txt">others</a>.
Distributed under the terms of the
<a href="{project_url}/blob/master/LICENSE.txt">MIT License</a>.
</p>
<p>
<p>Certain source files under other compatible permissive
licenses and/or originally by other authors.
Spyder 3 theme icons derived from
<a href="https://fontawesome.com/">Font Awesome</a> 4.7
(© 2016 David Gandy; SIL OFL 1.1) and
<a href="http://materialdesignicons.com/">Material Design</a>
(© 2014 Austin Andrews; SIL OFL 1.1).
Most Spyder 2 theme icons sourced from the
<a href="https://www.everaldo.com">Crystal Project iconset</a>
(© 2006-2007 Everaldo Coelho; LGPL 2.1+).
Other icons from
<a href="http://p.yusukekamiyamane.com/">Yusuke Kamiyamane</a>
(© 2013 Yusuke Kamiyamane; CC-BY 3.0),
the <a href="http://www.famfamfam.com/lab/icons/silk/">FamFamFam
Silk icon set</a> 1.3 (© 2006 Mark James; CC-BY 2.5), and
the <a href="https://www.kde.org/">KDE Oxygen icons</a>
(© 2007 KDE Artists; LGPL 3.0+).
</p>
<p>
Splash screen photo by
<a href="https://unsplash.com/@benchaccounting?utm_source=
unsplash&utm_medium=referral&utm_content=creditCopyText">Bench
Accounting</a> on <a href="https://unsplash.com/?utm_source=
unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash
</a>
</p>
<p>
See the
<a href="{project_url}/blob/master/NOTICE.txt">NOTICE</a>
file for full legal information.
</p>
</div>
""")
for label in [self.label_overview, self.label_community,
self.label_legal]:
label.setWordWrap(True)
label.setAlignment(Qt.AlignTop)
label.setOpenExternalLinks(True)
label.setTextInteractionFlags(Qt.TextBrowserInteraction)
label.setContentsMargins(15, 0, 25, 0)
icon_filename = "spyder_about"
pixmap = QPixmap(get_image_path(icon_filename))
self.label_pic = QLabel(self)
self.label_pic.setPixmap(
pixmap.scaledToWidth(100, Qt.SmoothTransformation))
self.label_pic.setAlignment(Qt.AlignBottom)
self.info = QLabel((
"""
<div style='font-family: "{font_family}";
font-size: {font_size};
font-weight: normal;
'>
<p>
<b>Spyder IDE</b>
<br>{spyder_ver}
<br>{revision}
<br>({installer})
<br>""").format(
spyder_ver=versions['spyder'],
revision=revlink,
installer=versions['installer'],
font_family=font_family,
font_size=font_size))
self.info.setAlignment(Qt.AlignHCenter)
btn = QPushButton(_("Copy version info"), )
bbox = QDialogButtonBox(QDialogButtonBox.Ok)
bbox.setStyleSheet(f"font-size: {buttons_font_size};"
f"padding: {buttons_padding}")
btn.setStyleSheet(f"font-size: {buttons_font_size};"
f"padding: {buttons_padding}")
# Widget setup
self.setWindowIcon(ima.icon('MessageBoxInformation'))
self.setModal(False)
# Layout
piclayout = QVBoxLayout()
piclayout.addWidget(self.label_pic)
piclayout.addWidget(self.info)
piclayout.setContentsMargins(20, 0, 15, 0)
scroll_overview = QScrollArea(self)
scroll_overview.setWidgetResizable(True)
scroll_overview.setWidget(self.label_overview)
scroll_community = QScrollArea(self)
scroll_community.setWidgetResizable(True)
scroll_community.setWidget(self.label_community)
scroll_legal = QScrollArea(self)
scroll_legal.setWidgetResizable(True)
scroll_legal.setWidget(self.label_legal)
self.tabs = QTabWidget()
self.tabs.addTab(scroll_overview, _('Overview'))
self.tabs.addTab(scroll_community, _('Community'))
self.tabs.addTab(scroll_legal, _('Legal'))
self.tabs.setStyleSheet(
f"background-color: {dialog_background_color}")
tabslayout = QHBoxLayout()
tabslayout.addWidget(self.tabs)
tabslayout.setSizeConstraint(tabslayout.SetFixedSize)
tabslayout.setContentsMargins(0, 15, 15, 0)
btmhlayout = QHBoxLayout()
btmhlayout.addWidget(btn)
btmhlayout.addWidget(bbox)
btmhlayout.setContentsMargins(100, 20, 0, 20)
btmhlayout.addStretch()
vlayout = QVBoxLayout()
vlayout.addLayout(tabslayout)
vlayout.addLayout(btmhlayout)
vlayout.setSizeConstraint(vlayout.SetFixedSize)
mainlayout = QHBoxLayout(self)
mainlayout.addLayout(piclayout)
mainlayout.addLayout(vlayout)
# Signals
btn.clicked.connect(self.copy_to_clipboard)
bbox.accepted.connect(self.accept)
# Size
self.resize(550, 430)
# Style
css = APP_STYLESHEET.get_copy()
css = css.get_stylesheet()
css.QDialog.setValues(backgroundColor=dialog_background_color)
css.QLabel.setValues(backgroundColor=dialog_background_color)
self.setStyleSheet(str(css))
def copy_to_clipboard(self):
QApplication.clipboard().setText(get_versions_text())
def test():
"""Run about widget test"""
from spyder.utils.qthelpers import qapplication
app = qapplication() # noqa
abt = AboutDialog(None)
abt.show()
sys.exit(abt.exec_())
if __name__ == '__main__':
test()