Tue, 19 Nov 2024 16:08:15 +0100
MicroPython
- Enhanced the WiFi and BLE detection for Pimoroni RP2350 boards because their firmware has modules for these even if the CYW43 chip is not present.
9844 | 1 | # -*- coding: utf-8 -*- |
2 | ||
10439
21c28b0f9e41
Updated copyright for 2024.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9979
diff
changeset
|
3 | # Copyright (c) 2023 - 2024 Detlev Offenbach <detlev@die-offenbachs.de> |
9844 | 4 | # |
5 | ||
6 | """ | |
7 | Module implementing a dialog to enter the package data for 'mip'. | |
8 | """ | |
9 | ||
10 | from PyQt6.QtCore import pyqtSlot | |
11 | from PyQt6.QtWidgets import QDialog, QDialogButtonBox | |
12 | from semver import VersionInfo | |
13 | ||
9979 | 14 | from .MipLocalInstaller import MicroPythonPackageIndex |
9844 | 15 | from .Ui_MipPackageDialog import Ui_MipPackageDialog |
16 | ||
17 | ||
18 | class MipPackageDialog(QDialog, Ui_MipPackageDialog): | |
19 | """ | |
20 | Class implementing a dialog to enter the package data for 'mip'. | |
21 | """ | |
22 | ||
23 | def __init__(self, parent=None): | |
24 | """ | |
25 | Constructor | |
26 | ||
27 | @param parent reference to the parent widget (defaults to None) | |
28 | @type QWidget (optional) | |
29 | """ | |
30 | super().__init__(parent) | |
31 | self.setupUi(self) | |
32 | ||
9979 | 33 | self.indexEdit.setToolTip( |
34 | self.tr( | |
35 | "Enter the URL of the package index. Leave empty to use the default" | |
36 | " index ({0})." | |
37 | ).format(MicroPythonPackageIndex) | |
38 | ) | |
39 | ||
9844 | 40 | self.packageEdit.textChanged.connect(self.__updateOk) |
41 | self.versionEdit.textChanged.connect(self.__updateOk) | |
42 | ||
43 | self.__updateOk() | |
44 | ||
45 | msh = self.minimumSizeHint() | |
46 | self.resize(max(self.width(), msh.width()), msh.height()) | |
47 | ||
48 | @pyqtSlot() | |
49 | def __updateOk(self): | |
50 | """ | |
51 | Private slot to set the enabled state of the OK button. | |
52 | """ | |
53 | enable = bool(self.packageEdit.text()) | |
54 | version = self.versionEdit.text() | |
55 | if version: | |
10643
08682797bfcd
Fixed a 'semver' compatibility issue in the CircuitPython updater and the MIP package dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
56 | try: |
08682797bfcd
Fixed a 'semver' compatibility issue in the CircuitPython updater and the MIP package dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
57 | enable &= VersionInfo.is_valid(version) |
08682797bfcd
Fixed a 'semver' compatibility issue in the CircuitPython updater and the MIP package dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
58 | except AttributeError: |
08682797bfcd
Fixed a 'semver' compatibility issue in the CircuitPython updater and the MIP package dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
59 | enable &= VersionInfo.isvalid(version) |
9844 | 60 | |
61 | self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(enable) | |
62 | ||
63 | def getData(self): | |
64 | """ | |
65 | Public method to get the entered package installation data. | |
66 | ||
9979 | 67 | @return tuple containing the package name, package version, a flag indicating |
68 | to install the package as '.mpy ' file, the target directory on the device | |
69 | and the package index to get the package from | |
70 | @rtype tuple of (str, str, bool, str, str) | |
9844 | 71 | """ |
72 | return ( | |
73 | self.packageEdit.text(), | |
74 | self.versionEdit.text(), | |
75 | self.mpyCheckBox.isChecked(), | |
9979 | 76 | self.targetEdit.text(), |
77 | self.indexEdit.text(), | |
9844 | 78 | ) |