source: orange/Orange/OrangeCanvas/application/aboutdialog.py @ 11122:652f979fd0a1

Revision 11122:652f979fd0a1, 1.7 KB checked in by Ales Erjavec <ales.erjavec@…>, 18 months ago (diff)

Added About widget dialog.

Line 
1"""
2Orange canvas about dialog
3"""
4
5import sys
6import pkg_resources
7
8from PyQt4.QtGui import QDialog, QDialogButtonBox, QVBoxLayout, QLabel, QPixmap
9from PyQt4.QtCore import Qt
10
11
12import Orange
13from Orange import OrangeCanvas
14
15ABOUT_TEMPLATE = """\
16<center>
17<h4>Orange</h4>
18<p>Version: {version}</p>
19<p>(hg revision: {hg_revision})</p>
20</center>
21
22"""
23
24
25class AboutDialog(QDialog):
26    def __init__(self, parent=None, **kwargs):
27        QDialog.__init__(self, parent, **kwargs)
28
29        if sys.platform == "darwin":
30            self.setAttribute(Qt.WA_MacSmallSize, True)
31
32        self.__setupUi()
33
34    def __setupUi(self):
35        layout = QVBoxLayout()
36        label = QLabel(self)
37
38        filename = pkg_resources.resource_filename(
39                        OrangeCanvas.__name__,
40                        "icons/orange-splash-screen.png")
41
42        label.setPixmap(QPixmap(filename))
43        layout.addWidget(label, Qt.AlignCenter)
44
45        try:
46            from Orange.version import version
47            from Orange.version import hg_revision
48        except ImportError:
49            dist = pkg_resources.get_distribution("Orange")
50            version = dist.version
51            hg_revision = "Unknown"
52
53        text = ABOUT_TEMPLATE.format(version=version,
54                                     hg_revision=hg_revision)
55        # TODO: Also list all known add-on versions.
56        text_label = QLabel(text)
57        layout.addWidget(text_label, Qt.AlignCenter)
58
59        buttons = QDialogButtonBox(QDialogButtonBox.Close,
60                                   Qt.Horizontal,
61                                   self)
62        layout.addWidget(buttons)
63        buttons.rejected.connect(self.accept)
64        layout.setSizeConstraint(QVBoxLayout.SetFixedSize)
65        self.setLayout(layout)
Note: See TracBrowser for help on using the repository browser.