¾È±Ô °øºÎ¹æ

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_())
 
¡Ø Ȥ½Ã µµ¿òÀÌ µÇ¼Ì´Ù¸é ´ñ±Û¿¡ ÇѸ¶µð ³²°ÜÁÖ¼¼¿ä!
ÀÛ¼ºÀÚ   ºñ¹Ð¹øÈ£
ÀÚµ¿±Û ¹æÁö     (ÀÚµ¿±Û ¹æÁö ±â´ÉÀÔ´Ï´Ù.)
³»¿ë   ´ñ±Û´Þ±â 
À̸ÞÀÏ ¹®ÀÇ : cak0280@nate.com  
Copyright 2000 By ENTERSOFT.KR All Rights Reserved.