# -*- coding: utf-8 -*- import sys from PyQt5.QtWidgets import QMainWindow, QApplication, QWidgetAction, QMenu class Example(QMainWindow): def __init__(self): super().__init__() self.toolbar = self.addToolBar('Toolbar') self.widgetAction = QWidgetAction(self.toolbar) self.menu = QMenu(self.toolbar) self.action1 = self.menu.addAction('action1') self.action2 = self.menu.addAction('action2') self.widgetAction.setText('demo') self.widgetAction.setMenu(self.menu) self.toolbar.addAction(self.widgetAction) self.action1.triggered.connect(self.onAction1) self.action2.triggered.connect(self.onAction2) self.widgetAction.triggered.connect(self.triggered) self.setGeometry(300, 300, 300, 200) self.setWindowTitle('Toolbar') def triggered(self, e): if self.widgetAction.text() == 'onAction1': self.action1.trigger() elif self.widgetAction.text() == 'onAction2': self.action2.trigger() def onAction1(self): print('onAction1') self.widgetAction.setText('onAction1') def onAction2(self): print('onAction2') self.widgetAction.setText('onAction2') if __name__ == '__main__': app = QApplication(sys.argv) ex = Example() ex.show() sys.exit(app.exec_())
2018년 11월 21일 수요일
[PyQt5] QWidgetAction sample
피드 구독하기:
댓글 (Atom)
docker redmine 설치
docker-composer.yml version: '3.1' services: redmine: image: redmine restart: always container_na...
-
용량이 큰 파일 업로드 시 net::ERR_CONNECTION_RESET 오류 발생할 경우. http_server = tornado.httpserver.HTTPServer(app, max_buffer_size=10485760000) upload_for...
-
# !-*- coding:utf-8 -*- import os import sys from PyQt5 import uic from PyQt5.QtCore import Qt from PyQt5.QtWidgets import QDialog , QAppl...
-
class Program { static void Main(String[] args) { string zipPath = "..."; string extractPath = Path.G...
댓글 없음:
댓글 쓰기