当前位置: 首页>>代码示例>>Python>>正文


Python QActionGroup.actions方法代码示例

本文整理汇总了Python中PyQt5.QtWidgets.QActionGroup.actions方法的典型用法代码示例。如果您正苦于以下问题:Python QActionGroup.actions方法的具体用法?Python QActionGroup.actions怎么用?Python QActionGroup.actions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtWidgets.QActionGroup的用法示例。


在下文中一共展示了QActionGroup.actions方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _get_menu

# 需要导入模块: from PyQt5.QtWidgets import QActionGroup [as 别名]
# 或者: from PyQt5.QtWidgets.QActionGroup import actions [as 别名]
 def _get_menu(self):
     # main menu
     menu = QMenu()
     main_menu_action_group = QActionGroup(menu)
     main_menu_action_group.setObjectName("main")
     # character menu
     map_action = QAction(menu)
     map_action.setText("Toggle Map")
     main_menu_action_group.addAction(map_action)
     separator = QAction(menu)
     separator.setSeparator(True)
     main_menu_action_group.addAction(separator)
     characters_action = QAction(menu)
     characters_action.setText("Switch Characters")
     main_menu_action_group.addAction(characters_action)
     separator = QAction(menu)
     separator.setSeparator(True)
     main_menu_action_group.addAction(separator)
     settings_action = QAction(menu)
     settings_action.setText("Settings")
     main_menu_action_group.addAction(settings_action)
     quit_action = QAction(menu)
     quit_action.setText("Quit")
     main_menu_action_group.addAction(quit_action)
     menu.addActions(main_menu_action_group.actions())
     menu.triggered[QAction].connect(self._menu_actions)
     return menu
开发者ID:nomns,项目名称:Parse99,代码行数:29,代码来源:parse99.py

示例2: MainWindow

# 需要导入模块: from PyQt5.QtWidgets import QActionGroup [as 别名]
# 或者: from PyQt5.QtWidgets.QActionGroup import actions [as 别名]
class MainWindow(QMainWindow, Ui_MainWindow):

    def __init__(self):
        QMainWindow.__init__(self)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.setWindowIcon(QIcon('icon.png'))

        self.ui.actionLoad_Lyrics.triggered.connect(self._load_lyrics_thread)
        self.cb_backends()

        # about widget
        self.aboutUi = About()
        self.ui.actionAbout.triggered.connect(self._about)
        self.aboutUi.setWindowModality(Qt.WindowModal)

        self._load_lyrics_thread()

    def cb_backends(self):
        self.cb_backends = QComboBox()

        self.cb_backends.addItem('Auto')

        menuLyricSource = QMenu(self.ui.menuEdit)
        menuLyricSource.setTitle('Lyric source')

        self.lyricGroup = QActionGroup(self)

        def addAction(name, checked=False):
            action = QAction(name, self)
            action.setText(name)
            action.setCheckable(True)
            action.setChecked(checked)
            action.setActionGroup(self.lyricGroup)

            return action

        menuLyricSource.addAction(addAction('Auto', True))
        menuLyricSource.addSeparator()
        menuLyricSource.triggered.connect(self._menu_backend_change)

        for backend in Pyrics.get_backends():
            menuLyricSource.addAction(addAction(backend.__name__))
            self.cb_backends.addItem(backend.__name__)

        self.ui.menuEdit.addMenu(menuLyricSource)
        self.ui.toolBar.addWidget(self.cb_backends)

        self.cb_backends.currentIndexChanged.connect(self._cb_backend_change)

    def _load_lyrics_thread(self):
        self.thread = LoadLyricsWorker(self.cb_backends.currentIndex(), self)

        self.thread.trigger.connect(self._load_lyrics)
        self.thread.start()

    def _load_lyrics(self, content):
        self.ui.txLyrics.setText(content)

    def _about(self):
        self.aboutUi.show()

    def _menu_backend_change(self, action):
        index = self.cb_backends.findText(action.text())
        self._update_backend(index)

    def _cb_backend_change(self, item):
        self._update_backend(item)

    def _update_backend(self, index):
        """Keep lyrics source combo in sync with the lyrics source in the menu"""
        if index >= 0:
            self.cb_backends.setCurrentIndex(index)
            name = self.cb_backends.currentText()

            for action in self.lyricGroup.actions():
                action.setChecked(False)
                if action.text() == name:
                    action.setChecked(True)
开发者ID:xcution,项目名称:pyrics,代码行数:82,代码来源:qpyrics.py

示例3: Ui_MainWindow

# 需要导入模块: from PyQt5.QtWidgets import QActionGroup [as 别名]
# 或者: from PyQt5.QtWidgets.QActionGroup import actions [as 别名]

#.........这里部分代码省略.........

        self.actionRunObjectTracking.triggered.connect(self.runObjectTracking)
        self.actionTrackingPathColor.triggered.connect(self.openTrackingPathColorSelectorDialog)

        self.menuAlgorithmsActionGroup = QActionGroup(self.menuAlgorithms)

        path_list = [[tracking_system_path, currentDirPath], ]
        if os.path.exists(user_defined_lib_path):
            path_list.append([user_defined_tracking_system_path, user_defined_lib_path])
        for system_path in path_list:
            for module_path in get_modules(system_path[0], system_path[1]):
                module_str = '.'.join(module_path)

                try:
                    module = importlib.import_module(module_str)

                    if not hasattr(module, 'Widget'):
                        continue

                    class_def = getattr(module, "Widget")
                    if not issubclass(class_def, QtWidgets.QWidget):
                        continue

                    widget = class_def(self.stackedWidget)
                    widget.reset.connect(self.resetDataframe)
                    widget.restart.connect(self.restartDataframe)
                    self.stackedWidget.addWidget(widget)

                    action = self.menuAlgorithms.addAction(widget.get_name())
                    action.triggered.connect(self.generateAlgorithmsMenuClicked(widget))
                    action.setCheckable(True)
                    action.setActionGroup(self.menuAlgorithmsActionGroup)

                    if len(self.menuAlgorithmsActionGroup.actions()) == 1:
                        action.setChecked(True)
                        self.algorithmSettingsGroupBox.setTitle(widget.get_name())

                except Exception as e:
                    if system_path[1] is user_defined_lib_path:
                        msg = 'Tracking Lib. Load Fail: {0}\n{1}'.format(module_str, e)
                        self.generateCriticalMessage(msg)
                    continue

    def openTrackingPathColorSelectorDialog(self, activated=False):
        if self.trackingPathGroup is not None:
            self.trackingPathGroup.openColorSelectorDialog(self)

    def generateAlgorithmsMenuClicked(self, widget):
        def action_triggered(activated=False):
            if widget is not self.stackedWidget.currentWidget():
                self.stackedWidget.setCurrentWidget(widget)
            else:
                pass
        return action_triggered

    def initializeEventDialog(self):
        quit_msg = "Data is not saved.\nAre you sure you want to reset?"
        reply = QtWidgets.QMessageBox.question(
                self,
                'Warning',
                quit_msg,
                QtWidgets.QMessageBox.Yes,
                QtWidgets.QMessageBox.No
                )

        if reply == QtWidgets.QMessageBox.Yes:
开发者ID:Licht-T,项目名称:UMATracker-Detect-Center,代码行数:70,代码来源:main.py

示例4: MainWindow

# 需要导入模块: from PyQt5.QtWidgets import QActionGroup [as 别名]
# 或者: from PyQt5.QtWidgets.QActionGroup import actions [as 别名]

#.........这里部分代码省略.........

    def createIconSizeGroupBox(self):
        self.iconSizeGroupBox = QGroupBox("Icon Size")

        self.smallRadioButton = QRadioButton()
        self.largeRadioButton = QRadioButton()
        self.toolBarRadioButton = QRadioButton()
        self.listViewRadioButton = QRadioButton()
        self.iconViewRadioButton = QRadioButton()
        self.tabBarRadioButton = QRadioButton()
        self.otherRadioButton = QRadioButton("Other:")

        self.otherSpinBox = IconSizeSpinBox()
        self.otherSpinBox.setRange(8, 128)
        self.otherSpinBox.setValue(64)

        self.smallRadioButton.toggled.connect(self.changeSize)
        self.largeRadioButton.toggled.connect(self.changeSize)
        self.toolBarRadioButton.toggled.connect(self.changeSize)
        self.listViewRadioButton.toggled.connect(self.changeSize)
        self.iconViewRadioButton.toggled.connect(self.changeSize)
        self.tabBarRadioButton.toggled.connect(self.changeSize)
        self.otherRadioButton.toggled.connect(self.changeSize)
        self.otherSpinBox.valueChanged.connect(self.changeSize)

        otherSizeLayout = QHBoxLayout()
        otherSizeLayout.addWidget(self.otherRadioButton)
        otherSizeLayout.addWidget(self.otherSpinBox)
        otherSizeLayout.addStretch()

        layout = QGridLayout()
        layout.addWidget(self.smallRadioButton, 0, 0)
        layout.addWidget(self.largeRadioButton, 1, 0)
        layout.addWidget(self.toolBarRadioButton, 2, 0)
        layout.addWidget(self.listViewRadioButton, 0, 1)
        layout.addWidget(self.iconViewRadioButton, 1, 1)
        layout.addWidget(self.tabBarRadioButton, 2, 1)
        layout.addLayout(otherSizeLayout, 3, 0, 1, 2)
        layout.setRowStretch(4, 1)
        self.iconSizeGroupBox.setLayout(layout)

    def createActions(self):
        self.addImagesAct = QAction("&Add Images...", self, shortcut="Ctrl+A",
                triggered=self.addImage)

        self.removeAllImagesAct = QAction("&Remove All Images", self,
                shortcut="Ctrl+R", triggered=self.removeAllImages)

        self.exitAct = QAction("&Quit", self, shortcut="Ctrl+Q",
                triggered=self.close)

        self.styleActionGroup = QActionGroup(self)
        for styleName in QStyleFactory.keys():
            action = QAction(self.styleActionGroup,
                    text="%s Style" % styleName, checkable=True,
                    triggered=self.changeStyle)
            action.setData(styleName)

        self.guessModeStateAct = QAction("&Guess Image Mode/State", self,
                checkable=True, checked=True)

        self.aboutAct = QAction("&About", self, triggered=self.about)

        self.aboutQtAct = QAction("About &Qt", self,
                triggered=QApplication.instance().aboutQt)

    def createMenus(self):
        self.fileMenu = self.menuBar().addMenu("&File")
        self.fileMenu.addAction(self.addImagesAct)
        self.fileMenu.addAction(self.removeAllImagesAct)
        self.fileMenu.addSeparator()
        self.fileMenu.addAction(self.exitAct)

        self.viewMenu = self.menuBar().addMenu("&View")
        for action in self.styleActionGroup.actions():
            self.viewMenu.addAction(action)
        self.viewMenu.addSeparator()
        self.viewMenu.addAction(self.guessModeStateAct)

        self.menuBar().addSeparator()

        self.helpMenu = self.menuBar().addMenu("&Help")
        self.helpMenu.addAction(self.aboutAct)
        self.helpMenu.addAction(self.aboutQtAct)

    def createContextMenu(self):
        self.imagesTable.setContextMenuPolicy(Qt.ActionsContextMenu)
        self.imagesTable.addAction(self.addImagesAct)
        self.imagesTable.addAction(self.removeAllImagesAct)

    def checkCurrentStyle(self):
        for action in self.styleActionGroup.actions():
            styleName = action.data()
            candidate = QStyleFactory.create(styleName)

            if candidate is None:
                return

            if candidate.metaObject().className() == QApplication.style().metaObject().className():
                action.trigger()
开发者ID:Axel-Erfurt,项目名称:pyqt5,代码行数:104,代码来源:icons.py

示例5: MainWindow

# 需要导入模块: from PyQt5.QtWidgets import QActionGroup [as 别名]
# 或者: from PyQt5.QtWidgets.QActionGroup import actions [as 别名]

#.........这里部分代码省略.........
        else:
            # No Spell check support
            self.actSpellcheck.setVisible(False)
            a = QAction(self.tr("Install PyEnchant to use spellcheck"), self)
            a.setIcon(self.style().standardIcon(QStyle.SP_MessageBoxWarning))
            a.triggered.connect(self.openPyEnchantWebPage, AUC)
            self.menuTools.addAction(a)

    ###############################################################################
    # SPELLCHECK
    ###############################################################################

    def updateMenuDict(self):

        if not enchant:
            return

        self.menuDict.clear()
        for i in enchant.list_dicts():
            a = QAction(str(i[0]), self)
            a.setCheckable(True)
            if settings.dict is None:
                settings.dict = enchant.get_default_language()
            if str(i[0]) == settings.dict:
                a.setChecked(True)
            a.triggered.connect(self.setDictionary, AUC)
            self.menuDictGroup.addAction(a)
            self.menuDict.addAction(a)

    def setDictionary(self):
        if not enchant:
            return

        for i in self.menuDictGroup.actions():
            if i.isChecked():
                # self.dictChanged.emit(i.text().replace("&", ""))
                settings.dict = i.text().replace("&", "")

                # Find all textEditView from self, and toggle spellcheck
                for w in self.findChildren(textEditView, QRegExp(".*"),
                                           Qt.FindChildrenRecursively):
                    w.setDict(settings.dict)

    def openPyEnchantWebPage(self):
        from PyQt5.QtGui import QDesktopServices
        QDesktopServices.openUrl(QUrl("http://pythonhosted.org/pyenchant/"))

    def toggleSpellcheck(self, val):
        settings.spellcheck = val

        # Find all textEditView from self, and toggle spellcheck
        for w in self.findChildren(textEditView, QRegExp(".*"),
                                   Qt.FindChildrenRecursively):
            w.toggleSpellcheck(val)

    ###############################################################################
    # SETTINGS
    ###############################################################################

    def settingsLabel(self):
        self.settingsWindow(3)

    def settingsStatus(self):
        self.settingsWindow(4)

    def settingsWindow(self, tab=None):
开发者ID:tdannecy,项目名称:manuskript,代码行数:70,代码来源:mainWindow.py

示例6: setupTextActions

# 需要导入模块: from PyQt5.QtWidgets import QActionGroup [as 别名]
# 或者: from PyQt5.QtWidgets.QActionGroup import actions [as 别名]
    def setupTextActions(self):
        tb = QToolBar(self)
        tb.setWindowTitle("Format Actions")
        self.addToolBar(tb)

        menu = QMenu("F&ormat", self)
        self.menuBar().addMenu(menu)

        self.actionTextBold = QAction(
                QIcon.fromTheme('format-text-bold',
                        QIcon(rsrcPath + '/textbold.png')),
                "&Bold", self, priority=QAction.LowPriority,
                shortcut=Qt.CTRL + Qt.Key_B, triggered=self.textBold,
                checkable=True)
        bold = QFont()
        bold.setBold(True)
        self.actionTextBold.setFont(bold)
        tb.addAction(self.actionTextBold)
        menu.addAction(self.actionTextBold)

        self.actionTextItalic = QAction(
                QIcon.fromTheme('format-text-italic',
                        QIcon(rsrcPath + '/textitalic.png')),
                "&Italic", self, priority=QAction.LowPriority,
                shortcut=Qt.CTRL + Qt.Key_I, triggered=self.textItalic,
                checkable=True)
        italic = QFont()
        italic.setItalic(True)
        self.actionTextItalic.setFont(italic)
        tb.addAction(self.actionTextItalic)
        menu.addAction(self.actionTextItalic)

        self.actionTextUnderline = QAction(
                QIcon.fromTheme('format-text-underline',
                        QIcon(rsrcPath + '/textunder.png')),
                "&Underline", self, priority=QAction.LowPriority,
                shortcut=Qt.CTRL + Qt.Key_U, triggered=self.textUnderline,
                checkable=True)
        underline = QFont()
        underline.setUnderline(True)
        self.actionTextUnderline.setFont(underline)
        tb.addAction(self.actionTextUnderline)
        menu.addAction(self.actionTextUnderline)

        menu.addSeparator()

        grp = QActionGroup(self, triggered=self.textAlign)

        # Make sure the alignLeft is always left of the alignRight.
        if QApplication.isLeftToRight():
            self.actionAlignLeft = QAction(
                    QIcon.fromTheme('format-justify-left',
                            QIcon(rsrcPath + '/textleft.png')),
                    "&Left", grp)
            self.actionAlignCenter = QAction(
                    QIcon.fromTheme('format-justify-center',
                            QIcon(rsrcPath + '/textcenter.png')),
                    "C&enter", grp)
            self.actionAlignRight = QAction(
                    QIcon.fromTheme('format-justify-right',
                            QIcon(rsrcPath + '/textright.png')),
                    "&Right", grp)
        else:
            self.actionAlignRight = QAction(
                    QIcon.fromTheme('format-justify-right',
                            QIcon(rsrcPath + '/textright.png')),
                    "&Right", grp)
            self.actionAlignCenter = QAction(
                    QIcon.fromTheme('format-justify-center',
                            QIcon(rsrcPath + '/textcenter.png')),
                    "C&enter", grp)
            self.actionAlignLeft = QAction(
                    QIcon.fromTheme('format-justify-left',
                            QIcon(rsrcPath + '/textleft.png')),
                    "&Left", grp)
 
        self.actionAlignJustify = QAction(
                QIcon.fromTheme('format-justify-fill',
                        QIcon(rsrcPath + '/textjustify.png')),
                "&Justify", grp)

        self.actionAlignLeft.setShortcut(Qt.CTRL + Qt.Key_L)
        self.actionAlignLeft.setCheckable(True)
        self.actionAlignLeft.setPriority(QAction.LowPriority)

        self.actionAlignCenter.setShortcut(Qt.CTRL + Qt.Key_E)
        self.actionAlignCenter.setCheckable(True)
        self.actionAlignCenter.setPriority(QAction.LowPriority)

        self.actionAlignRight.setShortcut(Qt.CTRL + Qt.Key_R)
        self.actionAlignRight.setCheckable(True)
        self.actionAlignRight.setPriority(QAction.LowPriority)

        self.actionAlignJustify.setShortcut(Qt.CTRL + Qt.Key_J)
        self.actionAlignJustify.setCheckable(True)
        self.actionAlignJustify.setPriority(QAction.LowPriority)

        tb.addActions(grp.actions())
        menu.addActions(grp.actions())
        menu.addSeparator()
#.........这里部分代码省略.........
开发者ID:inzem77,项目名称:ws-chat2,代码行数:103,代码来源:textEdit.py

示例7: KEyesWidget

# 需要导入模块: from PyQt5.QtWidgets import QActionGroup [as 别名]
# 或者: from PyQt5.QtWidgets.QActionGroup import actions [as 别名]

#.........这里部分代码省略.........

    for name in sorted(self.faces):

      action = QAction(name, self.actionFaces)
      action.setCheckable(True)
      allFaceActions.append(action)

    self.actionFaces.triggered.connect(self.actionUpdateFace)

    startAction = random.choice(allFaceActions)
    startAction.setChecked(True)
    self.actionUpdateFace(startAction)

    self.actionQuit = QAction("Quit", self)
    self.actionQuit.triggered.connect(QApplication.instance().quit)

    self.timer = QTimer()
    self.timer.timeout.connect(self.updateFromMousePosition)

    self.timer.start(self.update_interval)

    self.painter = None


  def actionUpdateFace(self, action):

    self.setFace(action.text())


  def setFace(self, name):

    self.setWindowTitle(name)
    self.pixmap = QPixmap(normalize_path(self.faces[name][0]))

    self.setWindowIcon(QIcon(self.pixmap))

    self.eyes = [Eye(*self.faces[name][1]), Eye(*self.faces[name][2])]

    self.setMask(self.pixmap.createHeuristicMask())

    if self.isVisible():
      self.update()


  def updateFromMousePosition(self):

    newPosition = QCursor.pos()

    if newPosition == self.mousePosition:
      return

    self.mousePosition = newPosition

    if self.isVisible():
      self.update()


  def mousePressEvent(self, event):

    if event.button() == Qt.LeftButton:

      self.dragPosition = event.globalPos() - self.frameGeometry().topLeft()
      event.accept()


  def mouseMoveEvent(self, event):

    if event.buttons() == Qt.LeftButton:

      self.move(event.globalPos() - self.dragPosition)
      event.accept()


  def contextMenuEvent(self, event):

    menu = QMenu(self)

    menu.addActions(self.actionFaces.actions())
    menu.addSeparator()
    menu.addAction(self.actionQuit)

    menu.exec_(event.globalPos())


  def paintEvent(self, event):

    painter      = QPainter(self)
    self.painter = painter

    painter.drawPixmap(QPoint(0, 0), self.pixmap)

    for eye in self.eyes:
      eye.render(self)

    self.painter = None


  def sizeHint(self):

    return self.pixmap.size()
开发者ID:pvaret,项目名称:keyes,代码行数:104,代码来源:KEyes.py

示例8: __init__

# 需要导入模块: from PyQt5.QtWidgets import QActionGroup [as 别名]
# 或者: from PyQt5.QtWidgets.QActionGroup import actions [as 别名]
	def __init__(self, supported_exts, parent=None):
		super().__init__(parent)

		self._diasshowRunning = False
		# a dummy widget to center actions
		spacer1 = QWidget()
		spacer1.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
		self.addWidget(spacer1)

		self.supportedExts = supported_exts
		self._fromFile = self.addAction(QIcon("icons/image-outline.svg"), "", self.chooseFile) # load images from file
		self._fromFile.setToolTip("Load image")
		self._fromFolder = self.addAction(QIcon("icons/folder-open.svg"), "", self.chooseFolder) # load images from folder
		self._fromFolder.setToolTip("Load from directory")

		# View in native size, fit width, fit height or fit image
		self._imageMode = QToolButton(self)
		self._imageMode.setIcon(QIcon("icons/eye-outline.svg"))
		self._imageMode.setToolTip("Image view mode")
		self._imageMode.setPopupMode(QToolButton.InstantPopup)
		self.addWidget(self._imageMode)
		
		# imageMode menu
		imageModeMenu = QMenu(self)
		imageModeActions = QActionGroup(imageModeMenu)
		imModeAct1 = imageModeActions.addAction("Native size")
		imModeAct1.setCheckable(True)
		imModeAct1.triggered.connect(lambda: self.imageModeChanged.emit(0))
		imModeAct2 = imageModeActions.addAction("Fit in view")
		imModeAct2.setCheckable(True)
		imModeAct2.triggered.connect(lambda: self.imageModeChanged.emit(1))
		imModeAct3 = imageModeActions.addAction("Fit width")
		imModeAct3.setCheckable(True)
		imModeAct3.triggered.connect(lambda: self.imageModeChanged.emit(2))
		imModeAct4 = imageModeActions.addAction("Fit height")
		imModeAct4.setCheckable(True)
		imModeAct4.triggered.connect(lambda: self.imageModeChanged.emit(3))
		imageModeActions.setExclusive(True)
		imageModeMenu.addActions(imageModeActions.actions())
		self._imageMode.setMenu(imageModeMenu)

		
		self._imgDirection = self.addAction(QIcon("icons/arrow-move-outline.svg"), "", self.imageDirectionChanged.emit) # Horizontal or Vertical
		self._imgDirection.setToolTip("Toggle image direction")

		# start or stop diasshow
		self._playDias = self.addAction(QIcon("icons/media-play-outline.svg"), "", self.diasshowState)
		self._playDias.setToolTip("Start/stop diasshow")

		#diasshow menu
		self._diasMenu = QMenu(self)
		self._diasMenu.addAction("5 seconds", lambda: self.diasshowState(5))
		self._diasMenu.addAction("10 seconds", lambda: self.diasshowState(10))
		self._diasMenu.addAction("30 seconds", lambda: self.diasshowState(30))
		self._diasMenu.addAction("5 minutes", lambda: self.diasshowState(60*5))
		self._diasMenu.addAction("10 minutes", lambda: self.diasshowState(600))
		self._playDias.setMenu(self._diasMenu)


		self._zoomIn = self.addAction(QIcon("icons/zoom-in-outline.svg"), "", lambda: self.zoomChanged.emit(True))
		self._zoomOut = self.addAction(QIcon("icons/zoom-out-outline.svg"), "", lambda: self.zoomChanged.emit(False))
		self._rotateCW = self.addAction(QIcon("icons/rotate-cw-outline.svg"), "", self.rotateChanged.emit) # Clockwise
		self._rotateCW.setToolTip("Rotate Clockwise")
		#self._rotateCCW = self.addAction("Rotate Left") # Counter clockwise

		# a dummy widget to center actions
		spacer2 = QWidget()
		spacer2.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
		self.addWidget(spacer2)
开发者ID:iSplasher,项目名称:happyview,代码行数:71,代码来源:controls.py

示例9: Gui

# 需要导入模块: from PyQt5.QtWidgets import QActionGroup [as 别名]
# 或者: from PyQt5.QtWidgets.QActionGroup import actions [as 别名]

#.........这里部分代码省略.........
                    color = self.device.red_vel
                else:
                    color = self.device.black_vel
                self.queue_out.put(((self.NOTEON << 4) + b_channel,
                                    b_pitch,
                                    color))
        else:
            x, y = -1, -1
            try:
                x, y = self.device.getXY(btn_id)
            except IndexError:
                pass
            except KeyError:
                try:
                    x, y = self.device.getXY(btn_id_vel)
                except KeyError:
                    pass

            if (x >= 0 and y >= 0):
                self.startStop(x, y)

    def toggleBlinkButton(self):
        for line in self.btn_matrix:
            for btn in line:
                if btn.blink:
                    if self.blktimer.state:
                        btn.setStyleSheet(btn.color)
                    else:
                        btn.setStyleSheet(self.DEFAULT)
        if self.song.is_record:
            if self.blktimer.state:
                self.recordButton.setStyleSheet(self.RECORD_BLINK)
            else:
                self.recordButton.setStyleSheet(self.RECORD_DEFAULT)

        self.blktimer.state = not self.blktimer.state

    def updateProgress(self):
        state, pos = self._jack_client.transport_query()
        if 'bar' in pos:
            bbt = "%d|%d|%03d" % (pos['bar'], pos['beat'], pos['tick'])
        else:
            bbt = "-|-|-"
        seconds = int(pos['frame'] / pos['frame_rate'])
        (minutes, second) = divmod(seconds, 60)
        (hour, minute) = divmod(minutes, 60)
        time = "%d:%02d:%02d" % (hour, minute, second)
        self.bbtLabel.setText("%s\n%s" % (bbt, time))
        for line in self.btn_matrix:
            for btn in line:
                if btn.clip and btn.clip.audio_file:
                    value = ((btn.clip.last_offset
                              / self.song.length(btn.clip))
                             * 97)
                    btn.clip_position.setValue(value)
                    btn.clip_position.repaint()

    def updateDevices(self):
        for action in self.deviceGroup.actions():
            self.deviceGroup.removeAction(action)
            self.menuDevice.removeAction(action)
        for device in self.devices:
            action = QAction(device.name, self.menuDevice)
            action.setCheckable(True)
            action.setData(device)
            self.menuDevice.addAction(action)
            self.deviceGroup.addAction(action)
        action.setChecked(True)
        self.device = device

    def addDevice(self, device):
        self.devices.append(device)
        self.updateDevices()
        self.is_learn_device_mode = False

    def onDeviceSelect(self):
        self.device = self.deviceGroup.checkedAction().data()
        if self.device:
            if self.device.init_command:
                for note in self.device.init_command:
                    self.queue_out.put(note)
            self.redraw()

    def timebase_callback(self, state, nframes, pos, new_pos):
        if pos.frame_rate == 0:
            return None
        pos.valid = 0x10
        pos.bar_start_tick = BAR_START_TICK
        pos.beats_per_bar = self.beat_per_bar.value()
        pos.beat_type = BEAT_TYPE
        pos.ticks_per_beat = TICKS_PER_BEAT
        pos.beats_per_minute = self.bpm.value()
        ticks_per_second = (pos.beats_per_minute *
                            pos.ticks_per_beat) / 60
        ticks = (ticks_per_second * pos.frame) / pos.frame_rate
        (beats, pos.tick) = divmod(int(round(ticks, 0)),
                                   int(round(pos.ticks_per_beat, 0)))
        (bar, beat) = divmod(beats, int(round(pos.beats_per_bar, 0)))
        (pos.bar, pos.beat) = (bar + 1, beat + 1)
        return None
开发者ID:sonejostudios,项目名称:superboucle,代码行数:104,代码来源:gui.py

示例10: Gui

# 需要导入模块: from PyQt5.QtWidgets import QActionGroup [as 别名]
# 或者: from PyQt5.QtWidgets.QActionGroup import actions [as 别名]

#.........这里部分代码省略.........
                                    b_pitch,
                                    color))
        else:
            x, y = -1, -1
            try:
                x, y = self.device.getXY(btn_id)
            except IndexError:
                pass
            except KeyError:
                try:
                    x, y = self.device.getXY(btn_id_vel)
                except KeyError:
                    pass

            if (x >= 0 and y >= 0):
                self.startStop(x, y)

    def setCellColor(self, x, y, color, blink=False):
        self.btn_matrix[x][y].setStyleSheet(color)
        self.btn_matrix[x][y].blink = blink
        self.btn_matrix[x][y].color = color

    def toogleBlinkButton(self):
        for line in self.btn_matrix:
            for btn in line:
                if btn.blink:
                    if self.blktimer.state:
                        btn.setStyleSheet(btn.color)
                    else:
                        btn.setStyleSheet(self.DEFAULT)
        if self.song.is_record:
            if self.blktimer.state:
                self.recordButton.setStyleSheet(self.RECORD_BLINK)
            else:
                self.recordButton.setStyleSheet(self.RECORD_DEFAULT)

        self.blktimer.state = not self.blktimer.state

    def updateProgress(self):
        state, pos = self._jack_client.transport_query()
        if 'bar' in pos:
            bbt = "%d|%d|%03d" % (pos['bar'], pos['beat'], pos['tick'])
        else:
            bbt = "-|-|-"
        seconds = int(pos['frame'] / pos['frame_rate'])
        (minutes, second) = divmod(seconds, 60)
        (hour, minute) = divmod(minutes, 60)
        time = "%d:%02d:%02d" % (hour, minute, second)
        self.bbtLabel.setText("%s\n%s" % (bbt, time))
        for line in self.btn_matrix:
            for btn in line:
                if btn.clip and btn.clip.audio_file:
                    value = ((btn.clip.last_offset
                              / self.song.length(btn.clip))
                             * 97)
                    btn.clip_position.setValue(value)
                    btn.clip_position.repaint()

    def updateDevices(self):
        for action in self.deviceGroup.actions():
            self.deviceGroup.removeAction(action)
            self.menuDevice.removeAction(action)
        for device in self.devices:
            action = QAction(device.name, self.menuDevice)
            action.setCheckable(True)
            action.setData(device)
            self.menuDevice.addAction(action)
            self.deviceGroup.addAction(action)
        action.setChecked(True)
        self.device = device

    def addDevice(self, device):
        self.devices.append(device)
        self.updateDevices()
        self.is_learn_device_mode = False

    def onDeviceSelect(self):
        self.device = self.deviceGroup.checkedAction().data()
        if self.device:
            if self.device.init_command:
                for note in self.device.init_command:
                    self.queue_out.put(note)
            self.redraw()

    def timebase_callback(self, state, nframes, pos, new_pos):
        pos.valid = 0x10
        pos.bar_start_tick = BAR_START_TICK
        pos.beats_per_bar = self.beat_per_bar.value()
        pos.beat_type = BEAT_TYPE
        pos.ticks_per_beat = TICKS_PER_BEAT
        pos.beats_per_minute = self.bpm.value()
        ticks = frame2bbt(pos.frame,
                          pos.ticks_per_beat,
                          pos.beats_per_minute,
                          pos.frame_rate)
        (beats, pos.tick) = divmod(int(round(ticks, 0)),
                                   int(round(pos.ticks_per_beat, 0)))
        (bar, beat) = divmod(beats, int(round(pos.beats_per_bar, 0)))
        (pos.bar, pos.beat) = (bar + 1, beat + 1)
        return None
开发者ID:piloudsda,项目名称:superboucle,代码行数:104,代码来源:gui.py


注:本文中的PyQt5.QtWidgets.QActionGroup.actions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。