src/eric7/MicroPython/WifiDialogs/WifiCountryDialog.py

branch
mpy_network
changeset 9779
8d3c7c991085
child 10439
21c28b0f9e41
equal deleted inserted replaced
9776:210bf87ae5c7 9779:8d3c7c991085
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2023 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6
7 """
8 Module implementing a dialog to enter the country code for the WiFi interface.
9 """
10
11 from PyQt6.QtCore import pyqtSlot
12 from PyQt6.QtWidgets import QDialog, QDialogButtonBox
13
14 from eric7 import Preferences
15
16 from .Ui_WifiCountryDialog import Ui_WifiCountryDialog
17
18
19 class WifiCountryDialog(QDialog, Ui_WifiCountryDialog):
20 """
21 Class implementing a dialog to enter the country code for the WiFi interface.
22 """
23
24 def __init__(self, parent=None):
25 """
26 Constructor
27
28 @param parent reference to the parent widget (defaults to None)
29 @type QWidget (optional)
30 """
31 super().__init__(parent)
32 self.setupUi(self)
33
34 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False)
35
36 self.countryEdit.setText(Preferences.getMicroPython("WifiCountry").upper())
37
38 msh = self.minimumSizeHint()
39 self.resize(max(self.width(), msh.width()), msh.height())
40
41 @pyqtSlot(str)
42 def on_countryEdit_textChanged(self, country):
43 """
44 Private slot handling a change of the country.
45
46 @param country entered country code
47 @type str
48 """
49 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(
50 bool(country)
51 )
52
53 def getCountry(self):
54 """
55 Public method to get the entered country code.
56
57 @return tuple containing the country code and a flag indicating to save it to
58 the settings
59 @rtype tuple of (str, bool)
60 """
61 return self.countryEdit.text().upper(), self.rememberCheckBox.isChecked()

eric ide

mercurial