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


Python QMenu.setTearOffEnabled方法代码示例

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


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

示例1: _create_theme_menu

# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import setTearOffEnabled [as 别名]
    def _create_theme_menu(self):
        theme_menu = QMenu(self)
        theme_menu.setTitle('Buttons Theme')
        theme_menu.setTearOffEnabled(True)
        theme_menu.setWindowTitle(TAG)
        theme_actions = QActionGroup(self)
        theme_actions.setExclusive(True)
        # create ordered theme list
        custom_order_theme = sorted(THEMES.iterkeys())
        custom_order_theme.remove('Maya Theme')
        custom_order_theme.insert(0, 'Maya Theme')
        default_item = True
        for theme in custom_order_theme:
            current_theme_action = QAction(theme, theme_actions)
            current_theme_action.setCheckable(True)
            current_theme_action.setChecked(
                MTTSettings.value('theme', 'Maya Theme') == theme)
            current_theme_action.triggered.connect(self.on_change_theme)
            theme_menu.addAction(current_theme_action)

            if default_item:
                theme_menu.addSeparator()
                default_item = False

        return theme_menu
开发者ID:Bioeden,项目名称:dbMayaTextureToolkit,代码行数:27,代码来源:mttSettingsMenu.py

示例2: javaLoadCommand

# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import setTearOffEnabled [as 别名]

#.........这里部分代码省略.........
                findNextIndex = False
        else:
            ch = script[index]
            if ch == '(':
                funcName = script[funcNameIndex:index].strip()
                funcList.append(funcName)
                funcName = ""
                findNextIndex = True
            else:
                index += 1

    validBeforeChars = (  # QList<QChar>
        '\t', '\n', '\v', '\f', '\r', ' ', ';', '(', ')',
        '{', '}', 'not ', '=', '+', '-', '/', '*', '%',
        '<', '>', '&', '|', '?', ':', '^', '~')

    validAfterChars = ('\t', '\n', '\v', '\f', '\r', ' ', '(')  # QList<QChar>
    for functionName in funcList:
        findFunc = functionName
        funcName = cmdName + "_" + functionName

        found = 0
        done = False
        index = 0
        findNextIndex = True
        while not done:
            if findNextIndex:
                index = script.find(findFunc, index)
                if index == -1:
                    done = True
                else:
                    findNextIndex = False
            else:
                charBefore = script[index - 1]
                if charBefore in validBeforeChars:
                    i = 0
                    while True:
                        charAfter = script[index + i + len(findFunc)]  # QChar
                        if charAfter == '(':
                            found += 1
                            ##script.replace(index, len(findFunc), funcName)
                            #TODO/FIXME/PORT# inmprove this
                            script = script[:index] + funcName + script[index+len(findFunc):]
                            ##script.replace(findFunc, funcName)

                        i += 1

                        if charAfter not in validAfterChars:
                            break

                index += len(findFunc)
                findNextIndex = True

        qDebug("%s found: %d" % (qPrintable(findFunc), found))

    #TODO: low priority caveat: If a function name is within a string, is still replaced.

    script.replace("global = {};", "var " + cmdName + "_global = {};")
    script.replace("global.", cmdName + "_global.")

    self.engine.evaluate(script)

    #TODO/PORT/FIXME#
    settings = QSettings(appDir + "/commands/" + cmdName + "/" + cmdName + ".ini", QSettings.IniFormat)
    menuName = str(settings.value("Menu/Name", "Lost & Found"))  # .toString()
    menuPos = int(settings.value("Menu/Position", 0))  # .toInt()
    toolbarName = str(settings.value("ToolBar/Name", "Lost & Found"))  # .toString()
    toolbarPos = int(settings.value("ToolBar/Position", 0))  # .toInt()
    toolTip = str(settings.value("Tips/ToolTip", ""))  # .toString()
    statusTip = str(settings.value("Tips/StatusTip", ""))  # .toString()
    aliases = settings.value("Prompt/Alias") or []  # .toStringList()

    ACTION = self.createAction(cmdName, toolTip, statusTip, True)

    if toolbarName.upper() != "NONE":
        # If the toolbar doesn't exist, it.
        if toolbarName not in self.toolbarHash:
            tb = QToolBar(toolbarName, self)
            tb.setObjectName("toolbar" + toolbarName)
            tb.topLevelChanged.connect(self.floatingChangedToolBar)
            self.addToolBar(Qt.LeftToolBarArea, tb)
            self.addToolBarBreak(Qt.LeftToolBarArea)
            self.toolbarHash[toolbarName] = tb

        # TODO: order actions position in toolbar based on .ini setting
        self.toolbarHash[toolbarName].addAction(ACTION)

    if menuName.upper() != "NONE":
        # If the menu doesn't exist, it.
        if menuName not in self.menuHash:
            menu = QMenu(menuName, self)
            menu.setTearOffEnabled(True)
            self.menuBar().addMenu(menu)
            self.menuHash[menuName] = menu

        # TODO: order actions position in menu based on .ini setting
        self.menuHash[menuName].addAction(ACTION)

    for alias in aliases:
        self.prompt.addCommand(alias, cmdName)
开发者ID:Allen76,项目名称:Embroidermodder,代码行数:104,代码来源:native_javascript_init.py


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