2018년 10월 25일 목요일

[PyQt5] QToolButton example

#!/usr/bin/env python# -*- coding:utf-8 -*-import sys

from PyQt5 import uic
from PyQt5.QtWidgets import QMainWindow, QApplication, QWidgetAction, QAction, QToolButton

FORM_CLASS, _ = uic.loadUiType('./ui/main.ui')


class MainForm(QMainWindow, FORM_CLASS):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setupUi(self)
        self.toolbar = self.addToolBar(u'툴바')

        self._ac1 = QAction(u'액숀1', self)
        self._ac1.triggered.connect(self._action_01)

        self._ac2 = QAction(u'액숀2', self)
        self._ac2.triggered.connect(self._action_02)

        self._tb1 = QToolButton(self)

        self._tb1.addAction(self._ac1)
        self._tb1.addAction(self._ac2)

        self._tb1.setPopupMode(QToolButton.InstantPopup)
        self._tb1.setDefaultAction(self._ac1)

        self.toolbar.addWidget(self._tb1)

    def _action_01(self):
        self._tb1.setDefaultAction(self._ac1)

    def _action_02(self):
        self._tb1.setDefaultAction(self._ac2)


if __name__ == '__main__':
    app = QApplication(sys.argv)
    w = MainForm()
    w.show()
    sys.exit(app.exec())

댓글 없음:

댓글 쓰기

docker redmine 설치

docker-composer.yml version: '3.1' services:      redmine:           image: redmine           restart: always           container_na...