아미(아름다운미소)

Python PyQt5 submenu 본문

랭귀지/python

Python PyQt5 submenu

유키공 2018. 12. 11. 09:30

Python PyQt5 submenu

Python PyQt5 서브메뉴 예제
# -*- coding: utf-8 -*-
import sys
from PyQt5.QtWidgets import QMainWindow, QAction, QMenu, QApplication

class Example(QMainWindow):
    
    def __init__(self):
        super().__init__()
        
        self.initUI()
        
        
    def initUI(self):         
        
        menubar = self.menuBar()
        fileMenu = menubar.addMenu('파일')
        
        impMenu = QMenu('열기', self)
        impAct = QAction('서브메뉴열기', self) 
        impMenu.addAction(impAct)
        
        newAct = QAction('새파일', self)        
        
        fileMenu.addAction(newAct)
        fileMenu.addMenu(impMenu)
        
        self.setGeometry(300, 300, 300, 200)
        self.setWindowTitle('서브메뉴')    
        self.show()
        
        
if __name__ == '__main__':
    
    app = QApplication(sys.argv)
    ex = Example()
    sys.exit(app.exec_())


Comments