src/eric7/MicroPython/WifiDialogs/WifiCountryDialog.py

Thu, 23 Feb 2023 13:31:20 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 23 Feb 2023 13:31:20 +0100
branch
mpy_network
changeset 9794
21fd7c63b487
parent 9779
8d3c7c991085
child 10439
21c28b0f9e41
permissions
-rw-r--r--

MicroPython
- corrected a type in the WiFi controller

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

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


"""
Module implementing a dialog to enter the country code for the WiFi interface.
"""

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

from eric7 import Preferences

from .Ui_WifiCountryDialog import Ui_WifiCountryDialog


class WifiCountryDialog(QDialog, Ui_WifiCountryDialog):
    """
    Class implementing a dialog to enter the country code for the WiFi interface.
    """

    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.countryEdit.setText(Preferences.getMicroPython("WifiCountry").upper())

        msh = self.minimumSizeHint()
        self.resize(max(self.width(), msh.width()), msh.height())

    @pyqtSlot(str)
    def on_countryEdit_textChanged(self, country):
        """
        Private slot handling a change of the country.

        @param country entered country code
        @type str
        """
        self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(
            bool(country)
        )

    def getCountry(self):
        """
        Public method to get the entered country code.

        @return tuple containing the country code and a flag indicating to save it to
            the settings
        @rtype tuple of (str, bool)
        """
        return self.countryEdit.text().upper(), self.rememberCheckBox.isChecked()

eric ide

mercurial