Python ÇÁ·Î±×·¡¹Ö > PyQt5 - QtWidgets - QComboBox (ÄÞº¸¹Ú½º ¿¹Á¦)
µî·ÏÀÏ : 2018-07-11 16:09
Á¶È¸¼ö : 53,774
À̹ø¿¡´Â ÄÞº¸¹Ú½º ¿¹Á¦ ÀÔ´Ï´Ù.
ÄÞº¸¹Ú½º¸¦ Ãß°¡ÇÏ°í, ¼±Åýÿ¡ Label ¿¡ ¼±ÅÃµÈ °ªÀ» Ãâ·ÂÇØ ÁÖ´Â ¿¹Á¦ ÀÔ´Ï´Ù.
# -*- coding: utf-8 -*-
import sys
import codecs
from PyQt5.QtWidgets import QApplication, QMainWindow, QFileDialog, QMenuBar, QAction, QLabel, QComboBox, QWidget
from PyQt5.QtGui import QIcon
class Example(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.lbl = QLabel(self)
self.lbl.move(50, 50)
combo = QComboBox(self)
combo.addItem("µ¶¼ö¸®", "eagle")
combo.addItem("°¾ÆÁö", "puppy")
combo.addItem("°í¾çÀÌ", "cat")
combo.move(50, 100)
combo.activated.connect(self.changeCombo)
self.setGeometry(300, 300, 300, 200)
self.setWindowTitle('QSplitter')
self.show()
def changeCombo(self, text):
sender = self.sender()
idx = sender.currentIndex()
self.lbl.setText(sender.itemData(idx))
self.lbl.adjustSize()
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())