source: orange/Orange/OrangeCanvas/application/aboutdialog.py @ 11532:68ae91b09f62

Revision 11532:68ae91b09f62, 1.6 KB checked in by Ales Erjavec <ales.erjavec@…>, 11 months ago (diff)

Set the application version from the package info and display it in the splash screen.

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