本文整理汇总了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
示例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
示例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')
示例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')
示例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
示例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)
示例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;
示例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
示例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
示例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())
示例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
示例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
示例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()
示例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