eric6/CondaInterface/CondaPackageDetailsWidget.py

Sat, 31 Aug 2019 12:58:11 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 31 Aug 2019 12:58:11 +0200
branch
without_py2_and_pyqt4
changeset 7192
a22eee00b052
parent 6942
2602857055c5
child 7229
53054eb5b15a
permissions
-rw-r--r--

Started removing runtime support for Python2 and PyQt4.

6712
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
3 # Copyright (c) 2019 Detlev Offenbach <detlev@die-offenbachs.de>
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a widget and a dialog to show package details.
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 from __future__ import unicode_literals
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 from PyQt5.QtCore import Qt, QDateTime
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 from PyQt5.QtWidgets import QWidget, QDialog, QVBoxLayout, QDialogButtonBox
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 from .Ui_CondaPackageDetailsWidget import Ui_CondaPackageDetailsWidget
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 from Globals import dataString
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 class CondaPackageDetailsWidget(QWidget, Ui_CondaPackageDetailsWidget):
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 Class implementing a widget to show package details.
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 def __init__(self, details, parent=None):
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 Constructor
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 @param details dictionary containing the package details
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 @type dict
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 @param parent reference to the parent widget
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 @type QWidget
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 super(CondaPackageDetailsWidget, self).__init__(parent)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 self.setupUi(self)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 self.headerLabel.setText(self.tr("<b>{0} / {1} / {2}</b>").format(
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 details["name"], details["version"], details["build"]))
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 if "fn" in details:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 self.filenameLabel.setText(details["fn"])
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 if "size" in details:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 self.sizeLabel.setText(dataString(details["size"]))
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 if "channel" in details:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 self.channelLabel.setText(details["channel"])
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 if "url" in details:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 self.urlLabel.setText(details["url"])
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 if "md5" in details:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 self.md5Label.setText(details["md5"])
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 if "license" in details:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 self.licenseLabel.setText(details["license"])
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 if "subdir" in details:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 self.platformLabel.setText(details["subdir"])
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 elif "platform" in details:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 self.platformLabel.setText(details["platform"])
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 else:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 self.platformLabel.setText(self.tr("unknown"))
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 if "depends" in details:
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 self.dependenciesEdit.setPlainText("\n".join(details["depends"]))
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 if "timestamp" in details:
6713
84024511120e CondaPackageDetailsWidget: fixed calculation of the timestamp.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6712
diff changeset
60 dt = QDateTime.fromMSecsSinceEpoch(details["timestamp"], Qt.UTC)
6712
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 self.timestampLabel.setText(dt.toString("yyyy-MM-dd hh:mm:ss t"))
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62
6728
ba077788a882 Conda: continued implementing the conda menu functionality
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6713
diff changeset
63 self.resize(600, 450)
6712
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 class CondaPackageDetailsDialog(QDialog):
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 Class implementing a dialog to show package details.
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 def __init__(self, details, parent=None):
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 Constructor
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 @param details dictionary containing the package details
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 @type dict
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 @param parent reference to the parent widget
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 @type QWidget
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 """
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 super(CondaPackageDetailsDialog, self).__init__(parent)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 self.setSizeGripEnabled(True)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 self.__layout = QVBoxLayout(self)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 self.setLayout(self.__layout)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 self.__cw = CondaPackageDetailsWidget(details, self)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 size = self.__cw.size()
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 self.__layout.addWidget(self.__cw)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 self.__buttonBox = QDialogButtonBox(self)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 self.__buttonBox.setStandardButtons(QDialogButtonBox.Close)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 self.__layout.addWidget(self.__buttonBox)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 self.resize(size)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 self.setWindowTitle(self.tr("Package Details"))
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 self.__buttonBox.accepted.connect(self.accept)
91fa67e8ebbc Conda: implemented the package search and 'Show Details' functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 self.__buttonBox.rejected.connect(self.reject)

eric ide

mercurial