src/eric7/MicroPython/Devices/CircuitPythonUpdater/ShowInstalledDialog.py

branch
eric7
changeset 9756
9854647c8c5c
parent 9740
90072e10ae9b
child 10439
21c28b0f9e41
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/eric7/MicroPython/Devices/CircuitPythonUpdater/ShowInstalledDialog.py	Mon Feb 13 17:49:52 2023 +0100
@@ -0,0 +1,45 @@
+# -*- coding: utf-8 -*-
+
+# Copyright (c) 2023 Detlev Offenbach <detlev@die-offenbachs.de>
+#
+
+"""
+Module implementing a dialog to show the modules installed on the connected device.
+"""
+
+import circup
+
+from PyQt6.QtCore import Qt
+from PyQt6.QtWidgets import QDialog, QTreeWidgetItem
+
+from .Ui_ShowInstalledDialog import Ui_ShowInstalledDialog
+
+
+class ShowInstalledDialog(QDialog, Ui_ShowInstalledDialog):
+    """
+    Class implementing a dialog to show the modules installed on the connected device.
+    """
+
+    def __init__(self, devicePath, parent=None):
+        """
+        Constructor
+
+        @param devicePath path to the connected board
+        @type str
+        @param parent reference to the parent widget (defaults to None)
+        @type QWidget (optional)
+        """
+        super().__init__(parent)
+        self.setupUi(self)
+
+        self.modulesList.clear()
+        deviceModules = circup.get_device_versions(devicePath)
+        for name, metadata in deviceModules.items():
+            QTreeWidgetItem(
+                self.modulesList,
+                [name, metadata.get("__version__", self.tr("unknown"))],
+            )
+
+        self.modulesList.sortItems(0, Qt.SortOrder.AscendingOrder)
+        self.modulesList.resizeColumnToContents(0)
+        self.modulesList.resizeColumnToContents(1)

eric ide

mercurial