src/eric7/CondaInterface/CondaPackageDetailsWidget.py

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

eric ide

mercurial