1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
import sys
from PyQt5 import QtWidgets, QtCore
country_list = ['France', 'Royaume-Uni', 'Géorgie', 'Guinée', 'Indonésie', 'Île de Man', 'Islande', 'Japon', 'Kenya', 'Corée du Sud', 'Kosovo', 'Lesotho', 'Luxembourg', 'Nigéria', 'Suriname', 'Seychelles', 'Îles Turques-et-Caïques', 'Tchad', 'Tuvalu', 'Uganda', 'Uruguay', 'Saint-Vincent-et-les-Grenadines', 'Venezuela', 'Andorre', 'Arménie', 'Antigua-et-Barbuda', 'Azerbaïdjan', 'Burundi', 'Burkina Faso', 'Bangladesh']
class Ui_MainWindow(QtWidgets.QMainWindow):
def __init__(self) -> None:
super().__init__()
self.setWindowTitle("Test")
self.setFixedSize(479, 160)
self.centralwidget = QtWidgets.QWidget(self)
self.centralwidget.setObjectName("centralwidget")
self.comboBox = QtWidgets.QComboBox(self.centralwidget)
self.comboBox.setGeometry(QtCore.QRect(80, 48, 309, 26))
self.setCentralWidget(self.centralwidget)
self.create_items_country()
def create_items_country(self):
self.comboBox.addItems(country_list)
self.comboBox.model().sort(0, QtCore.Qt.AscendingOrder)
def display_country(self):
country = self.comboBox.currentText()
print(country)
myApp = QtWidgets.QApplication(sys.argv)
window = Ui_MainWindow()
window.show()
sys.exit(myApp.exec_()) |
Partager