src/eric7/MicroPython/WifiDialogs/WifiCountryDialog.py

Sat, 06 Jan 2024 15:21:02 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 06 Jan 2024 15:21:02 +0100
branch
eric7
changeset 10482
72d9b5ea39b4
parent 10439
21c28b0f9e41
child 11090
f5f5f5803935
permissions
-rw-r--r--

Changed some state/mode definitiuons to an enum.Enum class and corrected some code style and formatting issues.

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

# Copyright (c) 2023 - 2024 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