diff -r dba433b4f3d6 -r 85418cf03fdb ProjectDjangoTagsMenu/TimezoneSelectionDialog.py --- a/ProjectDjangoTagsMenu/TimezoneSelectionDialog.py Thu Dec 30 12:03:18 2021 +0100 +++ b/ProjectDjangoTagsMenu/TimezoneSelectionDialog.py Wed Sep 21 16:38:40 2022 +0200 @@ -17,6 +17,7 @@ """ Class implementing a dialog to select a time zone. """ + Timezones = { "Africa": [ "Abidjan", @@ -600,73 +601,70 @@ "Samoa", ], } - + def __init__(self, parent=None): """ Constructor - + @param parent reference to the parent widget @type QWidget """ super().__init__(parent) self.setupUi(self) - - self.buttonBox.button( - QDialogButtonBox.StandardButton.Ok).setEnabled(False) - + + self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False) + self.regionCombo.addItems([" "] + sorted(self.Timezones.keys())) - + def __updateOK(self): """ Private method to update the OK button. """ self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( - bool(self.regionCombo.currentText()) and - len(self.cityList.selectedItems()) == 1 + bool(self.regionCombo.currentText()) + and len(self.cityList.selectedItems()) == 1 ) - + @pyqtSlot(str) def on_regionCombo_currentTextChanged(self, region): """ Private slot handling the selection of a time zone region. - + @param region selected region @type str """ self.cityList.clear() if region in self.Timezones: self.cityList.addItems(sorted(self.Timezones[region])) - + self.__updateOK() - + @pyqtSlot() def on_cityList_itemSelectionChanged(self): """ Private slot handling a change of the city selection. """ self.__updateOK() - + def getData(self): """ Public method to retrieve the data. - + @return selected time zone @rtype str """ - if (self.regionCombo.currentText() and - len(self.cityList.selectedItems()) == 1): + if self.regionCombo.currentText() and len(self.cityList.selectedItems()) == 1: return "{0}/{1}".format( - self.regionCombo.currentText(), - self.cityList.selectedItems()[0].text() + self.regionCombo.currentText(), self.cityList.selectedItems()[0].text() ) else: return "" - + @staticmethod def getTimezone(parent=None): """ Public static method to select a time zone. - + @param parent reference to the parent widget @type QWidget @return tuple of selected time zone and flag indicating the acceptance