本文整理汇总了Python中PyQt4.QtGui.QTextDocument.setDefaultStyleSheet方法的典型用法代码示例。如果您正苦于以下问题:Python QTextDocument.setDefaultStyleSheet方法的具体用法?Python QTextDocument.setDefaultStyleSheet怎么用?Python QTextDocument.setDefaultStyleSheet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QTextDocument
的用法示例。
在下文中一共展示了QTextDocument.setDefaultStyleSheet方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FeatureShape
# 需要导入模块: from PyQt4.QtGui import QTextDocument [as 别名]
# 或者: from PyQt4.QtGui.QTextDocument import setDefaultStyleSheet [as 别名]
class FeatureShape(LabeledPolygonShape):
def draw(self, painter, xMap, yMap, canvasRect):
self._setup_painter(painter)
self._set_outer_pen_and_brush(painter, xMap, yMap)
rtmin = self.item.rtmin
rtmax = self.item.rtmax
mzmin = self.item.mzmin
mzmax = self.item.mzmax
self._draw_polygon(painter, xMap, yMap, (rtmin, rtmax, mzmin, mzmax))
self._set_inner_pen_and_brush(painter, xMap, yMap)
for mass_trace in self.item.mass_traces:
self._draw_polygon(painter, xMap, yMap, mass_trace)
if self.label is not None:
self._draw_label(painter, xMap, yMap)
def _draw_label(self, painter, xMap, yMap):
self.text = QTextDocument()
self.text.setDefaultStyleSheet("""div { color: rgb(%d, %d, %d); }""" % self.color)
self.text.setHtml("<div>%s</div>" % (self.label, ))
x0 = xMap.transform(self.item.rtmax)
# y0: height between m0 and m1 masstrace if m1 exists, else at height of m0
yi = sorted(m.mzmin for m in self.item.mass_traces)
if len(yi) >= 2:
y0 = yMap.transform(0.5 * yi[0] + 0.5 * yi[1])
else:
y0 = yMap.transform(yi[0])
h = self.text.size().height()
painter.translate(x0, y0 - 0.5 * h)
self.text.drawContents(painter)
示例2: PeakRangeShape
# 需要导入模块: from PyQt4.QtGui import QTextDocument [as 别名]
# 或者: from PyQt4.QtGui.QTextDocument import setDefaultStyleSheet [as 别名]
class PeakRangeShape(LabeledPolygonShape):
def draw(self, painter, xMap, yMap, canvasRect):
self._setup_painter(painter)
self._set_inner_pen_and_brush(painter, xMap, yMap)
self._draw_polygon(painter, xMap, yMap, self.item)
if self.label is not None:
self._draw_label(painter, xMap, yMap)
def _draw_label(self, painter, xMap, yMap):
self.text = QTextDocument()
self.text.setDefaultStyleSheet("""div { color: rgb(%d, %d, %d); }""" % self.color)
self.text.setHtml("<div>%s</div>" % (self.label, ))
x0 = xMap.transform(self.item.rtmax)
# y0: height between m0 and m1 masstrace if m1 exists, else at height of m0
y0 = yMap.transform(0.5 * self.item.mzmin + 0.5 * self.item.mzmax)
h = self.text.size().height()
painter.translate(x0, y0 - 0.5 * h)
self.text.drawContents(painter)