src/eric7/MicroPython/MicroPythonWebreplParametersDialog.py

Sat, 21 Oct 2023 18:18:19 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 21 Oct 2023 18:18:19 +0200
branch
eric7
changeset 10253
f9a0704d16b2
parent 10022
a95800b414b7
child 10439
21c28b0f9e41
permissions
-rw-r--r--

MicroPython interface
- Optimized the UF2 flash dialog mount point detection.

# -*- coding: utf-8 -*-

# Copyright (c) 2023 Detlev Offenbach <detlev@die-offenbachs.de>
#

"""
Module implementing a dialog to enter the parameters for the WebREPL server.
"""

from PyQt6.QtCore import pyqtSlot
from PyQt6.QtWidgets import QDialog, QDialogButtonBox

from .Ui_MicroPythonWebreplParametersDialog import Ui_MicroPythonWebreplParametersDialog


class MicroPythonWebreplParametersDialog(
    QDialog, Ui_MicroPythonWebreplParametersDialog
):
    """
    Class implementing a dialog to enter the parameters for the WebREPL server.
    """

    def __init__(self, parent=None):
        """
        Constructor

        @param parent reference to the parent widget (defaults to None)
        @type QWidget (optional)
        """
        super().__init__(parent)
        self.setupUi(self)

        self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False)

        self.passwordEdit.textChanged.connect(self.__updateOk)
        self.passwordConfirmEdit.textChanged.connect(self.__updateOk)

    @pyqtSlot()
    def __updateOk(self):
        """
        Private slot to update the enabled state of the OK button.
        """
        pw = self.passwordEdit.text()
        self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(
            4 <= len(pw) <= 9 and self.passwordConfirmEdit.text() == pw
        )

    def getParameters(self):
        """
        Public method to retrieve the entered data.

        @return tuple containing the password
        @rtype tuple of (str,)
        """
        return (self.passwordEdit.text(),)

eric ide

mercurial