本文整理汇总了Python中qgis.PyQt.QtGui.QFont.setBold方法的典型用法代码示例。如果您正苦于以下问题:Python QFont.setBold方法的具体用法?Python QFont.setBold怎么用?Python QFont.setBold使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgis.PyQt.QtGui.QFont
的用法示例。
在下文中一共展示了QFont.setBold方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: showFeatureAttributes
# 需要导入模块: from qgis.PyQt.QtGui import QFont [as 别名]
# 或者: from qgis.PyQt.QtGui.QFont import setBold [as 别名]
def showFeatureAttributes(self):
conflictItem = self.lastSelectedItem
self.oursgeom = None
self.theirsgeom = None
geoms = (self.oursgeom, self.theirsgeom)
self.currentConflictedAttributes = []
attribs = list(conflictItem.origin.keys())
self.attributesTable.setRowCount(len(attribs))
self.conflicted = []
for idx, name in enumerate(attribs):
font = QFont()
font.setBold(True)
font.setWeight(75)
item = QTableWidgetItem(name)
item.setFont(font)
self.attributesTable.setItem(idx, 3, item);
self.attributesTable.setItem(idx, 4, ValueItem(None, False));
try:
values = (conflictItem.origin[name], conflictItem.local[name], conflictItem.remote[name])
except Exception: #Local has been deleted
self._afterSolve(False)
self.solveModifyAndDelete(conflictItem.conflict.path, self.REMOTE)
return
except TypeError: #Remote has been deleted
self._afterSolve(False)
self.solveModifyAndDelete(conflictItem.conflict.path,self.LOCAL)
return
try:
geom = QgsGeometry.fromWkt(values[0])
except:
geom = None
if geom is not None:
self.theirsgeom = QgsGeometry().fromWkt(values[1])
self.oursgeom = QgsGeometry.fromWkt(values[2])
geoms = (self.oursgeom, self.theirsgeom)
ok = values[0] == values[1] or values[1] == values[2] or values[0] == values[2]
for i, v in enumerate(values):
self.attributesTable.setItem(idx, i, ValueItem(v, not ok, geoms));
if not ok:
self.conflicted.append(name)
else:
if values[0] == values[1]:
newvalue = values[2]
else:
newvalue = values[1]
self.attributesTable.setItem(idx, 4, ValueItem(newvalue, False, geoms));
self.attributesTable.resizeRowsToContents()
self.attributesTable.horizontalHeader().setMinimumSectionSize(150)
self.attributesTable.horizontalHeader().setStretchLastSection(True)
示例2: commitClicked
# 需要导入模块: from qgis.PyQt.QtGui import QFont [as 别名]
# 或者: from qgis.PyQt.QtGui.QFont import setBold [as 别名]
def commitClicked(self):
feature = self.listWidget.currentItem().feature
geom = None
self.attributesTable.setRowCount(len(feature))
for idx, attrname in enumerate(feature):
value = feature[attrname]
font = QFont()
font.setBold(True)
font.setWeight(75)
item = QTableWidgetItem(attrname)
item.setFont(font)
self.attributesTable.setItem(idx, 0, item);
self.attributesTable.setItem(idx, 1, QTableWidgetItem(str(value)));
if geom is None:
try:
geom = QgsGeometry.fromWkt(value)
except:
pass
self.attributesTable.resizeRowsToContents()
self.attributesTable.horizontalHeader().setMinimumSectionSize(150)
self.attributesTable.horizontalHeader().setStretchLastSection(True)
settings = QSettings()
prjSetting = settings.value('/Projections/defaultBehaviour')
settings.setValue('/Projections/defaultBehaviour', '')
types = ["Point", "LineString", "Polygon"]
layers = []
if geom is not None:
geomtype = types[int(geom.type())]
layer = loadLayerNoCrsDialog(geomtype + "?crs=EPSG:4326", "temp", "memory")
pr = layer.dataProvider()
feat = QgsFeature()
feat.setGeometry(geom)
pr.addFeatures([feat])
layer.updateExtents()
layer.selectAll()
layer.setExtent(layer.boundingBoxOfSelected())
layer.invertSelection()
symbol = QgsSymbolV2.defaultSymbol(layer.geometryType())
symbol.setColor(Qt.green)
symbol.setAlpha(0.5)
if QGis.QGIS_VERSION_INT < 29900:
layer.setRendererV2(QgsSingleSymbolRendererV2(symbol))
else:
layer.setRenderer(QgsSingleSymbolRenderer(symbol))
self.mapCanvas.setRenderFlag(False)
self.mapCanvas.setLayerSet([QgsMapCanvasLayer(layer)])
QgsMapLayerRegistry.instance().addMapLayer(layer, False)
self.mapCanvas.setExtent(layer.extent())
self.mapCanvas.setRenderFlag(True)
layers.append(layer)
else:
self.mapCanvas.setLayerSet([])
settings.setValue('/Projections/defaultBehaviour', prjSetting)
示例3: setLexers
# 需要导入模块: from qgis.PyQt.QtGui import QFont [as 别名]
# 或者: from qgis.PyQt.QtGui.QFont import setBold [as 别名]
def setLexers(self):
self.lexer = QsciLexerPython()
loadFont = self.settings.value("pythonConsole/fontfamilytext", "Monospace")
fontSize = self.settings.value("pythonConsole/fontsize", 10, type=int)
font = QFont(loadFont)
font.setFixedPitch(True)
font.setPointSize(fontSize)
font.setStyleHint(QFont.TypeWriter)
font.setStretch(QFont.SemiCondensed)
font.setLetterSpacing(QFont.PercentageSpacing, 87.0)
font.setBold(False)
self.lexer.setDefaultFont(font)
self.lexer.setDefaultColor(QColor(self.settings.value("pythonConsole/defaultFontColor", QColor(Qt.black))))
self.lexer.setColor(QColor(self.settings.value("pythonConsole/commentFontColor", QColor(Qt.gray))), 1)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/keywordFontColor", QColor(Qt.darkGreen))), 5)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/classFontColor", QColor(Qt.blue))), 8)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/methodFontColor", QColor(Qt.darkGray))), 9)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/decorFontColor", QColor(Qt.darkBlue))), 15)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/commentBlockFontColor", QColor(Qt.gray))), 12)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/singleQuoteFontColor", QColor(Qt.blue))), 4)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/doubleQuoteFontColor", QColor(Qt.blue))), 3)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/tripleSingleQuoteFontColor", QColor(Qt.blue))), 6)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/tripleDoubleQuoteFontColor", QColor(Qt.blue))), 7)
self.lexer.setFont(font, 1)
self.lexer.setFont(font, 3)
self.lexer.setFont(font, 4)
for style in range(0, 33):
paperColor = QColor(self.settings.value("pythonConsole/paperBackgroundColor", QColor(Qt.white)))
self.lexer.setPaper(paperColor, style)
self.api = QsciAPIs(self.lexer)
chekBoxAPI = self.settings.value("pythonConsole/preloadAPI", True, type=bool)
chekBoxPreparedAPI = self.settings.value("pythonConsole/usePreparedAPIFile", False, type=bool)
if chekBoxAPI:
pap = os.path.join(QgsApplication.pkgDataPath(), "python", "qsci_apis", "pyqgis.pap")
self.api.loadPrepared(pap)
elif chekBoxPreparedAPI:
self.api.loadPrepared(self.settings.value("pythonConsole/preparedAPIFile"))
else:
apiPath = self.settings.value("pythonConsole/userAPI", [])
for i in range(0, len(apiPath)):
self.api.load(apiPath[i])
self.api.prepare()
self.lexer.setAPIs(self.api)
self.setLexer(self.lexer)
示例4: __init__
# 需要导入模块: from qgis.PyQt.QtGui import QFont [as 别名]
# 或者: from qgis.PyQt.QtGui.QFont import setBold [as 别名]
def __init__(self, data=None):
"""Constructor."""
super(ProfileWidget, self).__init__()
# Attributes
self.widget_items = []
# Set data
if data:
self.data = data
# Set header
self.header_tree_widget = QTreeWidgetItem(
[tr('Classification'), tr('Affected'), tr('Displacement Rate')])
header_font = QFont()
header_font.setBold(True)
header_font.setPointSize(14)
self.header_tree_widget.setFont(0, header_font)
self.header_tree_widget.setFont(1, header_font)
self.header_tree_widget.setFont(2, header_font)
self.setHeaderItem(self.header_tree_widget)
self.header().setSectionResizeMode(0, QHeaderView.Stretch)
self.header().setSectionResizeMode(1, QHeaderView.Fixed)
self.header().setSectionResizeMode(2, QHeaderView.ResizeToContents)
self.header().setSectionsMovable(False)
示例5: setLexers
# 需要导入模块: from qgis.PyQt.QtGui import QFont [as 别名]
# 或者: from qgis.PyQt.QtGui.QFont import setBold [as 别名]
def setLexers(self):
self.lexer = QsciLexerPython()
loadFont = self.settings.value("pythonConsole/fontfamilytext", "Monospace")
fontSize = self.settings.value("pythonConsole/fontsize", 10, type=int)
font = QFont(loadFont)
font.setFixedPitch(True)
font.setPointSize(fontSize)
font.setStyleHint(QFont.TypeWriter)
font.setStretch(QFont.SemiCondensed)
font.setLetterSpacing(QFont.PercentageSpacing, 87.0)
font.setBold(False)
self.lexer.setDefaultFont(font)
self.lexer.setDefaultColor(QColor(self.settings.value("pythonConsole/defaultFontColor", QColor(Qt.black))))
self.lexer.setColor(QColor(self.settings.value("pythonConsole/commentFontColor", QColor(Qt.gray))), 1)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/keywordFontColor", QColor(Qt.darkGreen))), 5)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/classFontColor", QColor(Qt.blue))), 8)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/methodFontColor", QColor(Qt.darkGray))), 9)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/decorFontColor", QColor(Qt.darkBlue))), 15)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/commentBlockFontColor", QColor(Qt.gray))), 12)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/singleQuoteFontColor", QColor(Qt.blue))), 4)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/doubleQuoteFontColor", QColor(Qt.blue))), 3)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/tripleSingleQuoteFontColor", QColor(Qt.blue))), 6)
self.lexer.setColor(QColor(self.settings.value("pythonConsole/tripleDoubleQuoteFontColor", QColor(Qt.blue))), 7)
self.lexer.setColor(QColor(Qt.red), 14)
self.lexer.setFont(font, 1)
self.lexer.setFont(font, 2)
self.lexer.setFont(font, 3)
self.lexer.setFont(font, 4)
for style in range(0, 33):
paperColor = QColor(self.settings.value("pythonConsole/paperBackgroundColor", QColor(Qt.white)))
self.lexer.setPaper(paperColor, style)
self.setLexer(self.lexer)
示例6: ScriptEdit
# 需要导入模块: from qgis.PyQt.QtGui import QFont [as 别名]
# 或者: from qgis.PyQt.QtGui.QFont import setBold [as 别名]
#.........这里部分代码省略.........
self.setFoldMarginColors(foldColor, foldColor)
# Mark column 80 with vertical line
self.setEdgeMode(QsciScintilla.EdgeLine)
self.setEdgeColumn(80)
self.setEdgeColor(QColor(settings.value("pythonConsole/edgeColorEditor", QColor(self.EDGE_COLOR))))
# Indentation
self.setAutoIndent(True)
self.setIndentationsUseTabs(False)
self.setIndentationWidth(4)
self.setTabIndents(True)
self.setBackspaceUnindents(True)
self.setTabWidth(4)
self.setIndentationGuides(True)
# Autocompletion
self.setAutoCompletionThreshold(2)
self.setAutoCompletionSource(QsciScintilla.AcsAPIs)
self.setFonts(10)
self.initLexer()
def setFonts(self, size):
# Load font from Python console settings
settings = QgsSettings()
fontName = settings.value('pythonConsole/fontfamilytext', 'Monospace')
fontSize = int(settings.value('pythonConsole/fontsize', size))
self.defaultFont = QFont(fontName)
self.defaultFont.setFixedPitch(True)
self.defaultFont.setPointSize(fontSize)
self.defaultFont.setStyleHint(QFont.TypeWriter)
self.defaultFont.setBold(False)
self.boldFont = QFont(self.defaultFont)
self.boldFont.setBold(True)
self.italicFont = QFont(self.defaultFont)
self.italicFont.setItalic(True)
self.setFont(self.defaultFont)
self.setMarginsFont(self.defaultFont)
def initShortcuts(self):
(ctrl, shift) = (self.SCMOD_CTRL << 16, self.SCMOD_SHIFT << 16)
# Disable some shortcuts
self.SendScintilla(QsciScintilla.SCI_CLEARCMDKEY, ord('D') + ctrl)
self.SendScintilla(QsciScintilla.SCI_CLEARCMDKEY, ord('L') + ctrl)
self.SendScintilla(QsciScintilla.SCI_CLEARCMDKEY, ord('L') + ctrl +
shift)
self.SendScintilla(QsciScintilla.SCI_CLEARCMDKEY, ord('T') + ctrl)
# self.SendScintilla(QsciScintilla.SCI_CLEARCMDKEY, ord("Z") + ctrl)
# self.SendScintilla(QsciScintilla.SCI_CLEARCMDKEY, ord("Y") + ctrl)
# Use Ctrl+Space for autocompletion
self.shortcutAutocomplete = QShortcut(QKeySequence(Qt.CTRL +
Qt.Key_Space), self)
self.shortcutAutocomplete.setContext(Qt.WidgetShortcut)
self.shortcutAutocomplete.activated.connect(self.autoComplete)
def autoComplete(self):
self.autoCompleteFromAll()
示例7: SqlEdit
# 需要导入模块: from qgis.PyQt.QtGui import QFont [as 别名]
# 或者: from qgis.PyQt.QtGui.QFont import setBold [as 别名]
class SqlEdit(QsciScintilla):
LEXER_PYTHON = 0
LEXER_R = 1
def __init__(self, parent=None):
QsciScintilla.__init__(self, parent)
self.mylexer = None
self.api = None
self.setCommonOptions()
self.initShortcuts()
def setCommonOptions(self):
# Enable non-ASCII characters
self.setUtf8(True)
# Default font
font = QFont()
font.setFamily('Courier')
font.setFixedPitch(True)
font.setPointSize(10)
self.setFont(font)
self.setMarginsFont(font)
self.setBraceMatching(QsciScintilla.SloppyBraceMatch)
self.setWrapMode(QsciScintilla.WrapWord)
self.setWrapVisualFlags(QsciScintilla.WrapFlagByText,
QsciScintilla.WrapFlagNone, 4)
self.setSelectionForegroundColor(QColor('#2e3436'))
self.setSelectionBackgroundColor(QColor('#babdb6'))
# Show line numbers
self.setMarginWidth(1, '000')
self.setMarginLineNumbers(1, True)
self.setMarginsForegroundColor(QColor('#2e3436'))
self.setMarginsBackgroundColor(QColor('#babdb6'))
# Highlight current line
self.setCaretLineVisible(True)
self.setCaretLineBackgroundColor(QColor('#d3d7cf'))
# Folding
self.setFolding(QsciScintilla.BoxedTreeFoldStyle)
self.setFoldMarginColors(QColor('#d3d7cf'), QColor('#d3d7cf'))
# Mark column 80 with vertical line
self.setEdgeMode(QsciScintilla.EdgeLine)
self.setEdgeColumn(80)
self.setEdgeColor(QColor('#eeeeec'))
# Indentation
self.setAutoIndent(True)
self.setIndentationsUseTabs(False)
self.setIndentationWidth(4)
self.setTabIndents(True)
self.setBackspaceUnindents(True)
self.setTabWidth(4)
# Autocomletion
self.setAutoCompletionThreshold(2)
self.setAutoCompletionSource(QsciScintilla.AcsAPIs)
self.setAutoCompletionCaseSensitivity(False)
# Load font from Python console settings
settings = QgsSettings()
fontName = settings.value('pythonConsole/fontfamilytext', 'Monospace')
fontSize = int(settings.value('pythonConsole/fontsize', 10))
self.defaultFont = QFont(fontName)
self.defaultFont.setFixedPitch(True)
self.defaultFont.setPointSize(fontSize)
self.defaultFont.setStyleHint(QFont.TypeWriter)
self.defaultFont.setStretch(QFont.SemiCondensed)
self.defaultFont.setLetterSpacing(QFont.PercentageSpacing, 87.0)
self.defaultFont.setBold(False)
self.boldFont = QFont(self.defaultFont)
self.boldFont.setBold(True)
self.italicFont = QFont(self.defaultFont)
self.italicFont.setItalic(True)
self.setFont(self.defaultFont)
self.setMarginsFont(self.defaultFont)
self.initLexer()
def initShortcuts(self):
(ctrl, shift) = (self.SCMOD_CTRL << 16, self.SCMOD_SHIFT << 16)
# Disable some shortcuts
self.SendScintilla(QsciScintilla.SCI_CLEARCMDKEY, ord('D') + ctrl)
self.SendScintilla(QsciScintilla.SCI_CLEARCMDKEY, ord('L') + ctrl)
self.SendScintilla(QsciScintilla.SCI_CLEARCMDKEY, ord('L') + ctrl +
shift)
self.SendScintilla(QsciScintilla.SCI_CLEARCMDKEY, ord('T') + ctrl)
#.........这里部分代码省略.........
示例8: populate_classified_values
# 需要导入模块: from qgis.PyQt.QtGui import QFont [as 别名]
# 或者: from qgis.PyQt.QtGui.QFont import setBold [as 别名]
def populate_classified_values(
unassigned_values, assigned_values, default_classes,
list_unique_values, tree_mapping_widget):
"""Populate lstUniqueValues and treeClasses.from the parameters.
:param unassigned_values: List of values that haven't been assigned
to a class. It will be put in list_unique_values.
:type unassigned_values: list
:param assigned_values: Dictionary with class as the key and list of
value as the value of the dictionary. It will be put in
tree_mapping_widget.
:type assigned_values: dict
:param default_classes: Default classes from unit.
:type default_classes: list
:param list_unique_values: List Widget for unique values
:type list_unique_values: QListWidget
:param tree_mapping_widget: Tree Widget for classifying.
:type tree_mapping_widget: QTreeWidget
"""
# Populate the unique values list
list_unique_values.clear()
list_unique_values.setSelectionMode(
QAbstractItemView.ExtendedSelection)
for value in unassigned_values:
value_as_string = value is not None and str(value) or 'NULL'
list_item = QListWidgetItem(list_unique_values)
list_item.setFlags(
Qt.ItemIsEnabled
| Qt.ItemIsSelectable
| Qt.ItemIsDragEnabled)
list_item.setData(Qt.UserRole, value)
list_item.setText(value_as_string)
list_unique_values.addItem(list_item)
# Populate assigned values tree
tree_mapping_widget.clear()
bold_font = QFont()
bold_font.setItalic(True)
bold_font.setBold(True)
bold_font.setWeight(75)
tree_mapping_widget.invisibleRootItem().setFlags(
Qt.ItemIsEnabled)
for default_class in default_classes:
# Create branch for class
tree_branch = QTreeWidgetItem(tree_mapping_widget)
tree_branch.setFlags(
Qt.ItemIsDropEnabled | Qt.ItemIsEnabled)
tree_branch.setExpanded(True)
tree_branch.setFont(0, bold_font)
if 'name' in default_class:
default_class_name = default_class['name']
else:
default_class_name = default_class['key']
tree_branch.setText(0, default_class_name)
tree_branch.setData(0, Qt.UserRole, default_class['key'])
if 'description' in default_class:
tree_branch.setToolTip(0, default_class['description'])
# Assign known values
for value in assigned_values[default_class['key']]:
string_value = value is not None and str(value) or 'NULL'
tree_leaf = QTreeWidgetItem(tree_branch)
tree_leaf.setFlags(
Qt.ItemIsEnabled
| Qt.ItemIsSelectable
| Qt.ItemIsDragEnabled)
tree_leaf.setData(0, Qt.UserRole, value)
tree_leaf.setText(0, string_value)
示例9: QFont
# 需要导入模块: from qgis.PyQt.QtGui import QFont [as 别名]
# 或者: from qgis.PyQt.QtGui.QFont import setBold [as 别名]
# coding=utf-8
"""Fonts which are used in InaSAFE."""
from qgis.PyQt.QtGui import QFont
big_font = QFont()
big_font.setPointSize(80)
bold_font = QFont()
bold_font.setItalic(True)
bold_font.setBold(True)
bold_font.setWeight(75)