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


Python Widget.draw方法代码示例

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


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

示例1: draw

# 需要导入模块: from widget import Widget [as 别名]
# 或者: from widget.Widget import draw [as 别名]
    def draw(self, parentposn, phelper, outerbounds=None):
        '''Plot the data on a plotter.'''

        posn = Widget.draw(self, parentposn, phelper,
                           outerbounds=outerbounds)

        s = self.settings
        d = self.document

        # exit if hidden
        if s.hide:
            return

        d1 = s.get('data1').getData(d)
        d2 = s.get('data2').getData(d)
        dscale = s.get('scalePoints').getData(d)
        text = s.get('labels').getData(d, checknull=True)
        if not d1 or not d2:
            return

        x1, y1, x2, y2 = posn
        cliprect = qt4.QRectF( qt4.QPointF(x1, y1), qt4.QPointF(x2, y2) )
        painter = phelper.painter(self, posn)
        self.parent.setClip(painter, posn)

        # split parts separated by NaNs
        for v1, v2, scalings, textitems in document.generateValidDatasetParts(
            d1, d2, dscale, text):
            # convert data (chopping down length)
            v1d, v2d = v1.data, v2.data
            minlen = min(v1d.shape[0], v2d.shape[0])
            v1d, v2d = v1d[:minlen], v2d[:minlen]
            px, py = self.parent.graphToPlotCoords(v1d, v2d)

            # do fill1 (if any)
            if not s.Fill1.hide:
                self.parent.drawFillPts(painter, s.Fill1, cliprect, px, py)
            # do fill2
            if not s.Fill2.hide:
                self.parent.drawFillPts(painter, s.Fill2, cliprect, px, py)

            # plot line
            if not s.PlotLine.hide:
                painter.setBrush( qt4.QBrush() )
                painter.setPen(s.PlotLine.makeQPen(painter))
                pts = qt4.QPolygonF()
                utils.addNumpyToPolygonF(pts, px, py)
                utils.plotClippedPolyline(painter, cliprect, pts)

            # markers
            markersize = s.get('markerSize').convert(painter)
            pscale = None
            if scalings:
                pscale = scalings.data
            self.plotMarkers(painter, px, py, pscale, markersize, cliprect)

            # finally plot any labels
            if textitems and not s.Label.hide:
                self.drawLabels(painter, px, py, textitems, markersize)
开发者ID:JoonyLi,项目名称:veusz,代码行数:61,代码来源:nonorthpoint.py

示例2: draw

# 需要导入模块: from widget import Widget [as 别名]
# 或者: from widget.Widget import draw [as 别名]
        def draw(self, surface):
            if self.root is None:
                self.root = self.get_root()
            Widget.draw(self, surface)
            frameStart = datetime.now()
            frameInterval = timedelta(0, 1, 0) / 2
            amount = None

            try:
                while datetime.now() < frameStart + frameInterval:
                    amount = progressIterator.next()
                    if self.firstDraw is False:
                        self.firstDraw = True
                        break

            except StopIteration:
                self.dismiss()

            infoText = ""
            if amount is not None:

                if isinstance(amount, tuple):
                    if len(amount) > 2:
                        infoText = ": " + amount[2]

                    amount, max = amount[:2]

                else:
                    max = amount
                maxwidth = (self.width - self.margin * 2)
                if amount is None:
                    self.progressBar.width = maxwidth
                    self.progressBar.bg_color = (255, 255, 25, 255)
                elif isinstance(amount, basestring):
                    self.statusText = amount
                else:
                    self.progressAmount = amount
                    if isinstance(amount, (int, float)):
                        self.progressFraction = float(amount) / (float(max) or 1)
                        self.progressBar.width = maxwidth * self.progressFraction
                        self.statusText = str("{0} / {1}".format(amount, max))
                    else:
                        self.statusText = str(amount)

                if infoText:
                    self.statusText += infoText
开发者ID:Nerocat,项目名称:MCEdit-Unified,代码行数:48,代码来源:extended_widgets.py

示例3: draw

# 需要导入模块: from widget import Widget [as 别名]
# 或者: from widget.Widget import draw [as 别名]
    def draw(self, parentposn, phelper, outerbounds=None):
        '''Plot the function on a plotter.'''

        posn = Widget.draw(self, parentposn, phelper,
                           outerbounds=outerbounds)

        s = self.settings

        # exit if hidden
        if s.hide:
            return

        # ignore if function isn't sensible
        try:
            self.checker.check(s.function, s.variable)
        except RuntimeError, e:
            self.logEvalError(e)
            return
开发者ID:JoonyLi,项目名称:veusz,代码行数:20,代码来源:nonorthfunction.py


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