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


Python utils.isMac方法代码示例

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


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

示例1: _wrapWithBgColour

# 需要导入模块: from anki import utils [as 别名]
# 或者: from anki.utils import isMac [as 别名]
def _wrapWithBgColour(editor, color):
    """
    Wrap the selected text in an appropriate tag with a background color.
    """
    # On Linux, the standard 'hiliteColor' method works. On Windows and OSX
    # the formatting seems to get filtered out

    editor.web.eval("""
        if (!setFormat('hiliteColor', '%s')) {
            setFormat('backcolor', '%s');
        }
        """ % (color, color))

    if isWin or isMac:
        # remove all Apple style classes, which is needed for
        # text highlighting on platforms other than Linux
        editor.web.eval("""
            var matches = document.querySelectorAll(".Apple-style-span");
            for (var i = 0; i < matches.length; i++) {
                matches[i].removeAttribute("class");
            }
        """)


# UI element creation 
开发者ID:glutanimate,项目名称:mini-format-pack,代码行数:27,代码来源:main.py

示例2: _fetchWebpage

# 需要导入模块: from anki import utils [as 别名]
# 或者: from anki.utils import isMac [as 别名]
def _fetchWebpage(self, url):
        if isMac:
            context = _create_unverified_context()
            html = urlopen(url, context=context).read()
        else:
            headers = {'User-Agent': self.settings['userAgent']}
            html = get(url, headers=headers).content

        webpage = BeautifulSoup(html, 'html.parser')

        for tagName in self.settings['badTags']:
            for tag in webpage.find_all(tagName):
                tag.decompose()

        for c in webpage.find_all(text=lambda s: isinstance(s, Comment)):
            c.extract()

        return webpage 
开发者ID:luoliyan,项目名称:incremental-reading,代码行数:20,代码来源:importer.py

示例3: __init__

# 需要导入模块: from anki import utils [as 别名]
# 或者: from anki.utils import isMac [as 别名]
def __init__(self, parent, title):
        '''
        Set the modal status for the dialog, sets its layout to the
        return value of the _ui() method, and sets a default title.
        '''

        self._title = title if "FastWQ" in title else "FastWQ - " + title
        self._parent = parent
        super(Dialog, self).__init__(parent)

        self.setModal(True)
        self.setWindowFlags(
            self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
        self.setWindowIcon(APP_ICON)
        self.setWindowTitle(self._title)
        # 2 & 3 & mac compatible
        if isMac and sys.hexversion >= 0x03000000:
            QApplication.setStyle('Fusion') 
开发者ID:sth2018,项目名称:FastWordQuery,代码行数:20,代码来源:base.py

示例4: __init__

# 需要导入模块: from anki import utils [as 别名]
# 或者: from anki.utils import isMac [as 别名]
def __init__(self, parent, title):
        '''
        Set the modal status for the dialog, sets its layout to the
        return value of the _ui() method, and sets a default title.
        '''

        self._title = title
        self._parent = parent
        super(Dialog, self).__init__(parent)

        self.setModal(True)
        self.setWindowFlags(
            self.windowFlags() &
            ~Qt.WindowContextHelpButtonHint
        )
        self.setWindowIcon(APP_ICON)
        self.setWindowTitle(
            title if "FastWQ" in title
            else "FastWQ - " + title
        )
        # 2 & 3 & mac compatible
        if isMac and sys.hexversion >= 0x03000000:
            QApplication.setStyle('Fusion') 
开发者ID:sth2018,项目名称:FastWordQuery,代码行数:25,代码来源:base.py

示例5: getDictFieldsTable

# 需要导入模块: from anki import utils [as 别名]
# 或者: from anki.utils import isMac [as 别名]
def getDictFieldsTable(self):
        macLin = False
        if isMac  or isLin:
            macLin = True
        dictFields = QTableWidget()
        dictFields.setColumnCount(3)
        tableHeader = dictFields.horizontalHeader()
        tableHeader.setSectionResizeMode(0, QHeaderView.Stretch)
        tableHeader.setSectionResizeMode(1, QHeaderView.Stretch)
        tableHeader.setSectionResizeMode(2, QHeaderView.Fixed)
        dictFields.setRowCount(0)
        dictFields.setSortingEnabled(False)
        dictFields.setEditTriggers(QTableWidget.NoEditTriggers)
        dictFields.setSelectionBehavior(QAbstractItemView.SelectRows)
        dictFields.setColumnWidth(2, 40)
        tableHeader.hide()
        return dictFields 
开发者ID:mass-immersion-approach,项目名称:MIA-Dictionary-Addon,代码行数:19,代码来源:addTemplate.py

示例6: dictionaryInit

# 需要导入模块: from anki import utils [as 别名]
# 或者: from anki.utils import isMac [as 别名]
def dictionaryInit(term = False):
    shortcut = '(Ctrl+W)'
    if isMac:
        shortcut = '⌘W'
    if not mw.miaDictionary:
        mw.miaDictionary = DictInterface(mw, addon_path, welcomeScreen, term = term)
        mw.openMiDict.setText("Close Dictionary " + shortcut)
    elif mw.miaDictionary and mw.miaDictionary.isVisible():
        mw.miaDictionary.saveSizeAndPos()
        mw.miaDictionary.hide()
        mw.openMiDict.setText("Open Dictionary "+ shortcut)
    else:
        mw.miaDictionary.dict.close()
        mw.miaDictionary.dict.deleteLater()
        mw.miaDictionary.deleteLater()
        mw.miaDictionary = DictInterface(mw, addon_path, welcomeScreen, term = term)
        mw.openMiDict.setText("Close Dictionary "+ shortcut) 
开发者ID:mass-immersion-approach,项目名称:MIA-Dictionary-Addon,代码行数:19,代码来源:main.py

示例7: getProgressWidgetDefs

# 需要导入模块: from anki import utils [as 别名]
# 或者: from anki.utils import isMac [as 别名]
def getProgressWidgetDefs():
    progressWidget = QWidget(None)
    layout = QVBoxLayout()
    progressWidget.setFixedSize(400, 70)
    progressWidget.setWindowIcon(QIcon(join(addon_path, 'icons', 'mia.png')))
    progressWidget.setWindowTitle("Generating Definitions...")
    progressWidget.setWindowModality(Qt.ApplicationModal)
    bar = QProgressBar(progressWidget)
    if isMac:
        bar.setFixedSize(380, 50)
    else:
        bar.setFixedSize(390, 50)
    bar.move(10,10)
    per = QLabel(bar)
    per.setAlignment(Qt.AlignCenter)
    progressWidget.show()
    return progressWidget, bar; 
开发者ID:mass-immersion-approach,项目名称:MIA-Dictionary-Addon,代码行数:19,代码来源:main.py

示例8: getGroupTemplateTable

# 需要导入模块: from anki import utils [as 别名]
# 或者: from anki.utils import isMac [as 别名]
def getGroupTemplateTable(self):
        macLin = False
        if isMac  or isLin:
            macLin = True
        groupTemplates = QTableWidget()
        groupTemplates.setColumnCount(3)
        tableHeader = groupTemplates.horizontalHeader()
        tableHeader.setSectionResizeMode(0, QHeaderView.Stretch)
        tableHeader.setSectionResizeMode(1, QHeaderView.Fixed)
        tableHeader.setSectionResizeMode(2, QHeaderView.Fixed)
        groupTemplates.setRowCount(0)
        groupTemplates.setSortingEnabled(False)
        groupTemplates.setEditTriggers(QTableWidget.NoEditTriggers)
        groupTemplates.setSelectionBehavior(QAbstractItemView.SelectRows)
        if macLin:
            groupTemplates.setColumnWidth(1, 50)
            groupTemplates.setColumnWidth(2, 40)
        else:
            groupTemplates.setColumnWidth(1, 40)
            groupTemplates.setColumnWidth(2, 40)
        tableHeader.hide()
        return groupTemplates 
开发者ID:mass-immersion-approach,项目名称:MIA-Dictionary-Addon,代码行数:24,代码来源:addonSettings.py

示例9: setupDictionaries

# 需要导入模块: from anki import utils [as 别名]
# 或者: from anki.utils import isMac [as 别名]
def setupDictionaries(self):
        macLin = False
        if isMac  or isLin:
            macLin = True
        dictionaries = QTableWidget()
        dictionaries.setColumnCount(3)
        tableHeader = dictionaries.horizontalHeader()
        tableHeader.setSectionResizeMode(0, QHeaderView.Stretch)
        tableHeader.setSectionResizeMode(1, QHeaderView.Fixed)
        tableHeader.setSectionResizeMode(2, QHeaderView.Fixed)
        dictionaries.setRowCount(0)
        dictionaries.setSortingEnabled(False)
        dictionaries.setEditTriggers(QTableWidget.NoEditTriggers)
        dictionaries.setSelectionBehavior(QAbstractItemView.SelectRows)
        dictionaries.setColumnWidth(1, 40)
        if macLin:
            dictionaries.setColumnWidth(2, 40)
        else:
            dictionaries.setColumnWidth(2, 20)
        tableHeader.hide()
        return dictionaries 
开发者ID:mass-immersion-approach,项目名称:MIA-Dictionary-Addon,代码行数:23,代码来源:addDictGroup.py

示例10: setColors

# 需要导入模块: from anki import utils [as 别名]
# 或者: from anki.utils import isMac [as 别名]
def setColors(self):
        if self.dictInt.nightModeToggler.day :
            self.window.setPalette(self.dictInt.ogPalette)
            if isMac:
                self.templateCB.setStyleSheet(self.dictInt.getMacComboStyle())
                self.deckCB.setStyleSheet(self.dictInt.getMacComboStyle())
                self.definitions.setStyleSheet(self.dictInt.getMacTableStyle())
            else:
                self.templateCB.setStyleSheet('')
                self.deckCB.setStyleSheet('')
                self.definitions.setStyleSheet('')
        else:
            self.window.setPalette(self.dictInt.nightPalette)
            if isMac: 
                self.templateCB.setStyleSheet(self.dictInt.getMacNightComboStyle())
                self.deckCB.setStyleSheet(self.dictInt.getMacNightComboStyle())
            else:
                self.templateCB.setStyleSheet(self.dictInt.getComboStyle())
                self.deckCB.setStyleSheet(self.dictInt.getComboStyle())
            self.definitions.setStyleSheet(self.dictInt.getTableStyle()) 
开发者ID:mass-immersion-approach,项目名称:MIA-Dictionary-Addon,代码行数:22,代码来源:cardExporter.py

示例11: getDefinitions

# 需要导入模块: from anki import utils [as 别名]
# 或者: from anki.utils import isMac [as 别名]
def getDefinitions(self):
        macLin = False
        if isMac  or isLin:
            macLin = True
        definitions = QTableWidget()
        definitions.setColumnCount(3)
        tableHeader = definitions.horizontalHeader()
        vHeader = definitions.verticalHeader()
        vHeader.setSectionResizeMode(QHeaderView.ResizeToContents)
        tableHeader.setSectionResizeMode(0, QHeaderView.Fixed)
        definitions.setColumnWidth(1, 100)
        tableHeader.setSectionResizeMode(1, QHeaderView.Stretch)
        tableHeader.setSectionResizeMode(2, QHeaderView.Fixed)
        definitions.setRowCount(0)
        definitions.setSortingEnabled(False)
        definitions.setEditTriggers(QTableWidget.NoEditTriggers)
        definitions.setSelectionBehavior(QAbstractItemView.SelectRows)
        definitions.setColumnWidth(2, 40)
        tableHeader.hide()
        return definitions 
开发者ID:mass-immersion-approach,项目名称:MIA-Dictionary-Addon,代码行数:22,代码来源:cardExporter.py

示例12: mungeForPlatform

# 需要导入模块: from anki import utils [as 别名]
# 或者: from anki.utils import isMac [as 别名]
def mungeForPlatform(popen):
    if isWin:
        popen = [os.path.normpath(x) for x in popen]
        popen[0] += ".exe"
    elif not isMac:
        popen[0] += ".lin"
    return popen 
开发者ID:mass-immersion-approach,项目名称:MIA-Japanese-Add-on,代码行数:9,代码来源:reading.py

示例13: changedTab

# 需要导入模块: from anki import utils [as 别名]
# 或者: from anki.utils import isMac [as 别名]
def changedTab(self, i):
        if not isMac or sys.hexversion >= 0x03000000:
            # restore
            for k in range(0, len(self.tabs)):
                self.tab_widget.setTabIcon(k, self._NULL_ICON)
            # add flag
            self.tab_widget.setTabIcon(i, self._OK_ICON)
        self.tabs[i].build_layout() 
开发者ID:sth2018,项目名称:FastWordQuery,代码行数:10,代码来源:options.py

示例14: handleImageExport

# 需要导入模块: from anki import utils [as 别名]
# 或者: from anki.utils import isMac [as 别名]
def handleImageExport(self):
        if self.checkDict():
            mime = self.mw.app.clipboard().mimeData()
            clip = self.mw.app.clipboard().text()
            
            if not clip.endswith('.mp3') and mime.hasImage():
                image = mime.imageData()
                filename = str(time.time()) + '.png'
                fullpath = join(self.addonPath, 'temp', filename)
                maxW = self.config['maxWidth']
                maxH = self.config['maxHeight']
                image = image.scaled(QSize(maxW, maxH), Qt.KeepAspectRatio, Qt.SmoothTransformation)
                image.save(fullpath)
                self.image.emit([fullpath, filename]) 
            elif clip.endswith('.mp3'):
                if not isLin:
                    if isMac:
                        try:
                            clip = str(self.mw.app.clipboard().mimeData().urls()[0].url())
                        except:
                            return
                    if clip.startswith('file:///') and clip.endswith('.mp3'):
                        try:
                            if isMac:
                                path = clip.replace('file://', '', 1)
                            else:
                                path = clip.replace('file:///', '', 1)
                            temp, mp3 = self.moveAudioToTempFolder(path)
                            if mp3:
                                self.image.emit([temp, '[sound:' + mp3 + ']', mp3]) 
                        except:
                            return 
开发者ID:mass-immersion-approach,项目名称:MIA-Dictionary-Addon,代码行数:34,代码来源:midict.py


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