# -*- 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, QWidget)
# Local imports
from spyder import (__project_url__, __forum_url__,
__trouble_url__, __website_url__, get_versions)
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, SpyderPalette
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 = " (Commit:
%s)" % (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
self.label_overview = QLabel((
"""
Spyder IDE
The Scientific Python Development Environment |
Spyder-IDE.org
Python {python_ver} {bitness}-bit | Qt {qt_ver} | {qt_api} {qt_api_ver} | {os_name} {os_ver}
Created by Pierre Raybaut; current maintainer is Carlos Cordoba. Developed by the international Spyder community. Many thanks to all the Spyder beta testers and dedicated users.
For help with Spyder errors and crashes, please read our Troubleshooting Guide, and for bug reports and feature requests, visit our Github site. For project discussion, see our Google Group.
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 Anaconda and WinPython also contribute to this plan.
Copyright © 2009-2020 Spyder Project Contributors and others. Distributed under the terms of the MIT License.
Certain source files under other compatible permissive licenses and/or originally by other authors. Spyder 3 theme icons derived from Font Awesome 4.7 (© 2016 David Gandy; SIL OFL 1.1) and Material Design (© 2014 Austin Andrews; SIL OFL 1.1). Most Spyder 2 theme icons sourced from the Crystal Project iconset (© 2006-2007 Everaldo Coelho; LGPL 2.1+). Other icons from Yusuke Kamiyamane (© 2013 Yusuke Kamiyamane; CC-BY 3.0), the FamFamFam Silk icon set 1.3 (© 2006 Mark James; CC-BY 2.5), and the KDE Oxygen icons (© 2007 KDE Artists; LGPL 3.0+).
Splash screen photo by Bench Accounting on Unsplash
See the NOTICE file for full legal information.
Spyder IDE
{spyder_ver}
{revision}
""").format(
spyder_ver=versions['spyder'],
revision=revlink,
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):
versions = get_versions()
QApplication.clipboard().setText(
"* Spyder version: {spyder_ver} {revision}\n"
"* Python version: {python_ver} {bitness}-bit\n"
"* Qt version: {qt_ver}\n"
"* {qt_api} version: {qt_api_ver}\n"
"* Operating System: {os_name} {os_ver}".format(
spyder_ver=versions['spyder'],
revision=versions['revision'],
python_ver=versions['python'],
bitness=versions['bitness'],
qt_ver=versions['qt'],
qt_api=versions['qt_api'],
qt_api_ver=versions['qt_api_ver'],
os_name=versions['system'],
os_ver=versions['release']))
def test():
"""Run about widget test"""
from spyder.utils.qthelpers import qapplication
qapplication()
abt = AboutDialog(None)
abt.show()
sys.exit(abt.exec_())
if __name__ == '__main__':
test()