Python wx 模块,BufferedDC() 实例源码

我们从Python开源项目中,提取了以下16个代码示例,用于说明如何使用wx.BufferedDC()

项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def Clear(self):
        """Erase the window."""
        self.last_PointLabel = None  # reset pointLabel
        dc = wx.BufferedDC(wx.ClientDC(self.canvas), self._Buffer)
        bbr = wx.Brush(self.GetBackgroundColour(), wx.SOLID)
        dc.SetBackground(bbr)
        dc.SetBackgroundMode(wx.SOLID)
        dc.Clear()
        if self._antiAliasingEnabled:
            try:
                dc = wx.GCDC(dc)
            except Exception:
                pass
        dc.SetTextForeground(self.GetForegroundColour())
        dc.SetTextBackground(self.GetBackgroundColour())
        self.last_draw = None
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def _drawPointLabel(self, mDataDict):
        """Draws and erases pointLabels"""
        width = self._Buffer.GetWidth()
        height = self._Buffer.GetHeight()
        if sys.platform != "darwin":
            tmp_Buffer = wx.Bitmap(width, height)
            dcs = wx.MemoryDC()
            dcs.SelectObject(tmp_Buffer)
            dcs.Clear()
        else:
            tmp_Buffer = self._Buffer.GetSubBitmap((0, 0, width, height))
            dcs = wx.MemoryDC(self._Buffer)
        self._pointLabelFunc(dcs, mDataDict)  # custom user pointLabel function
        dc = wx.ClientDC(self.canvas)
        dc = wx.BufferedDC(dc, self._Buffer)
        # this will erase if called twice
        dc.Blit(0, 0, width, height, dcs, 0, 0, self._logicalFunction)
        if sys.platform == "darwin":
            self._Buffer = tmp_Buffer
项目:augment3D    作者:yulkang    | 项目源码 | 文件源码
def OnPaint(self, event):
        "Window 'paint' event."
        dc = wx.PaintDC(self.imView)
        dc = wx.BufferedDC(dc)

        # paint a background just so it isn't *so* boring.
        dc.SetBackground(wx.Brush("WHITE"))
        dc.Clear()
        dc.SetBrush(wx.Brush("GREY", wx.CROSSDIAG_HATCH))
        windowsize = self.imView.GetSizeTuple()
        dc.DrawRectangle(0, 0, windowsize[0], windowsize[1])
        bmpX0 = 0
        bmpY0 = 0
        if self.bitmap is not None:
            if self.loadCentered:
                bmpX0 = (windowsize[0] - self.bitmap.Width) / 2
                bmpY0 = (windowsize[1] - self.bitmap.Height) / 2
            dc.DrawBitmap(self.bitmap, bmpX0, bmpY0, False)

    # ------------------------------------------------------------
    #  ImFrame.ConvertWXToPIL()
    #  Expropriated from Andrea Gavana's
    #  ShapedButton.py in the wxPython dist
    # ------------------------------------------------------------
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def draw(self):
        if self.hist is None:
            return

        # get client device context buffer
        dc = wx.BufferedDC(wx.ClientDC(self), self.buffer)
        dc.Clear()
        # w, h = self.GetClientSize()

        # the main draw process 
        print("drawing histogram")
        dc.SetPen(wx.Pen((100,100,100), width=1, style=wx.SOLID))        
        for i in range(256):
            dc.DrawLine(i,80,i,80-self.hist[i])            
        dc.SetPen(wx.Pen((0,0,0), width=1, style=wx.SOLID))
        dc.DrawLine(self.x1, 80, self.x2, 0)
        dc.DrawLines([(0,0),(255,0),(255,80),(0,80),(0,0)])
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def update(self, pix):
        if self.ips == None: return
        lay(self.box, self.imgbox)
        dc = wx.BufferedDC(wx.ClientDC(self), self.buffer)
        #dc.BeginDrawing()
        dc.Clear()
        self.draw_image(dc, self.ips.img, self.ips.backimg, self.ips.backmode, 
            self.imgbox, self.scales[self.scaleidx], pix)

        #dc.EndDrawing()

        #cdc = wx.ClientDC(self)
        #cdc.BeginDrawing()
        if self.ips.roi != None:
            self.ips.roi.draw(dc, self.to_panel_coor)
        if self.ips.mark != None:
            self.ips.mark.draw(dc, self.to_panel_coor, cur=self.ips.cur, k = self.get_scale())
        #cdc.EndDrawing()
        if self.ips.unit!=(1,'pix'):
            self.draw_ruler(dc)
        dc.UnMask()
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def draw(self):
        l, t, r, b = 35,35,15,35
        w = self.width - l - r
        h = self.height - t - b
        if self.data is None:return
        dc = wx.BufferedDC(wx.ClientDC(self), self.buffer)
        dc.Clear()

        left, low, right, high = self.extent
        self.draw_coord(dc, w, h, l, t, r, b)
        for xs, ys, c, lw in self.data:
            ys = h+t - (ys - low)*(h/(high-low))
            xs = l+(xs-left)*(1.0/(right-left)*w)
            pts = list(zip(xs, ys))
            dc.SetPen(wx.Pen(c, width=lw, style=wx.SOLID))
            dc.DrawLines(pts)
项目:bids    作者:robertoostenveld    | 项目源码 | 文件源码
def OnPaint(self, event):
        "Window 'paint' event."
        dc = wx.PaintDC(self.imView)
        dc = wx.BufferedDC(dc)

        # paint a background just so it isn't *so* boring.
        dc.SetBackground(wx.Brush("WHITE"))
        dc.Clear()
        dc.SetBrush(wx.Brush("GREY", wx.CROSSDIAG_HATCH))
        windowsize = self.imView.GetSizeTuple()
        dc.DrawRectangle(0, 0, windowsize[0], windowsize[1])
        bmpX0 = 0
        bmpY0 = 0
        if self.bitmap is not None:
            if self.loadCentered:
                bmpX0 = (windowsize[0] - self.bitmap.Width) / 2
                bmpY0 = (windowsize[1] - self.bitmap.Height) / 2
            dc.DrawBitmap(self.bitmap, bmpX0, bmpY0, False)

    # ------------------------------------------------------------
    #  ImFrame.ConvertWXToPIL()
    #  Expropriated from Andrea Gavana's
    #  ShapedButton.py in the wxPython dist
    # ------------------------------------------------------------
项目:Gym_LineFollower    作者:Chachay    | 项目源码 | 文件源码
def OnTimer(self, event):
        if self.World is not None:
            # Graphics Update
            self.bdc = wx.BufferedDC(self.cdc, self.bmp)
            self.gcdc = wx.GCDC(self.bdc)
            self.gcdc.Clear()

            self.gcdc.SetPen(wx.Pen('white'))
            self.gcdc.SetBrush(wx.Brush('white'))
            self.gcdc.DrawRectangle(0,0,640,640)

            for ag in [self.World.A]:
                ag.Draw(self.gcdc)
            self.World.BBox.Draw(self.gcdc)
            self.World.Course.Draw(self.gcdc)
项目:squaremap3    作者:kawaiicthulhu    | 项目源码 | 文件源码
def UpdateDrawing(self):
        dc = wx.BufferedDC(wx.ClientDC(self), self._buffer)
        self.Draw(dc)
项目:python_2048    作者:OATOMO    | 项目源码 | 文件源码
def initBuffer(self):
        w,h = self.GetClientSize()  #????
        self.buffer = wx.EmptyBitmap(w,h) #????buffer,????BufferedDC???
项目:python_2048    作者:OATOMO    | 项目源码 | 文件源码
def drawAll(self):
        dc = wx.BufferedDC(wx.ClientDC(self),self.buffer)
        self.drawBg(dc)
        self.drawLogo(dc)
        self.drawLabel(dc)
        self.drawScore(dc)
        self.drawTiles(dc)
项目:python_2048    作者:OATOMO    | 项目源码 | 文件源码
def drawChange(self,score):
        dc = wx.BufferedDC(wx.ClientDC(self),self.buffer)
        if score:
            self.curScore += score
            if self.curScore > self.bstScore:
                self.bstScore = self.curScore
            self.drawScore(dc)
        self.drawTiles(dc)
#---end class
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def RefreshView(self):
        width, height = self.MessagePanel.GetClientSize()
        bitmap = wx.EmptyBitmap(width, height)
        dc = wx.BufferedDC(wx.ClientDC(self.MessagePanel), bitmap)
        dc.Clear()
        dc.BeginDrawing()

        if self.CurrentMessage is not None:

            dc.SetFont(self.Font)

            for button in self.LeftButtons + self.RightButtons:
                button.Draw(dc)

            message_idx = self.CurrentMessage
            message = self.LogMessages[message_idx]
            draw_date = True
            offset = 5
            while offset < height and message is not None:
                message.Draw(dc, offset, width, draw_date)
                offset += message.GetHeight(draw_date)

                previous_message, message_idx = self.GetPreviousMessage(message_idx)
                if previous_message is not None:
                    draw_date = message.Date != previous_message.Date
                message = previous_message

        dc.EndDrawing()

        self.MessageScrollBar.RefreshThumbPosition()
项目:BigBrotherBot-For-UrT43    作者:ptitbigorneau    | 项目源码 | 文件源码
def UpdateDrawing(self):
        dc = wx.BufferedDC(wx.ClientDC(self), self._buffer)
        self.Draw(dc)
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def RefreshView(self):
        self.RefreshCanvasPosition()

        width, height = self.GraphicsWindow.GetVirtualSize()
        bitmap = wx.EmptyBitmap(width, height)
        dc = wx.BufferedDC(wx.ClientDC(self.GraphicsWindow), bitmap)
        dc.Clear()
        dc.BeginDrawing()
        if self.DraggingAxesPanel is not None:
            destBBox = self.DraggingAxesBoundingBox
            srcBBox = self.DraggingAxesPanel.GetAxesBoundingBox()

            srcBmp = _convert_agg_to_wx_bitmap(self.DraggingAxesPanel.get_renderer(), None)
            srcDC = wx.MemoryDC()
            srcDC.SelectObject(srcBmp)

            dc.Blit(destBBox.x, destBBox.y,
                    int(destBBox.width), int(destBBox.height),
                    srcDC, srcBBox.x, srcBBox.y)
        dc.EndDrawing()

        if not self.Fixed or self.Force:
            self.Force = False
            refresh_graphics = True
        else:
            refresh_graphics = False

        if self.DraggingAxesPanel is not None and self.DraggingAxesPanel not in self.GraphicPanels:
            self.DraggingAxesPanel.RefreshViewer(refresh_graphics)
        for panel in self.GraphicPanels:
            if isinstance(panel, DebugVariableGraphicViewer):
                panel.RefreshViewer(refresh_graphics)
            else:
                panel.RefreshViewer()

        if self.CursorTick is not None:
            tick = self.CursorTick
        elif len(self.Ticks) > 0:
            tick = self.Ticks[-1]
        else:
            tick = None
        if tick is not None:
            self.TickLabel.SetLabel(label=_("Tick: %d") % tick)
            tick_duration = int(tick * self.Ticktime)
            not_null = False
            duration = ""
            for value, format in [(tick_duration / DAY, _("%dd")),
                                  ((tick_duration % DAY) / HOUR, _("%dh")),
                                  ((tick_duration % HOUR) / MINUTE, _("%dm")),
                                  ((tick_duration % MINUTE) / SECOND, _("%ds"))]:

                if value > 0 or not_null:
                    duration += format % value
                    not_null = True

            duration += _("%03gms") % (float(tick_duration % SECOND) / MILLISECOND)
            self.TickTimeLabel.SetLabel("t: %s" % duration)
        else:
            self.TickLabel.SetLabel("")
            self.TickTimeLabel.SetLabel("")
        self.TickSizer.Layout()
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def RefreshViewer(self):
        """
        Method that refresh the content displayed by Viewer
        """
        # Create buffered DC for drawing in panel
        width, height = self.GetSize()
        bitmap = wx.EmptyBitmap(width, height)
        dc = wx.BufferedDC(wx.ClientDC(self), bitmap)
        dc.Clear()

        # Get Graphics Context for DC, for anti-aliased and transparent
        # rendering
        gc = wx.GCDC(dc)

        gc.BeginDrawing()

        # Get first item
        item = self.ItemsDict.values()[0]

        # Get item variable path masked according Debug Variable Panel mask
        item_path = item.GetVariable(
                self.ParentWindow.GetVariableNameMask())

        # Draw item variable path at Viewer left side
        w, h = gc.GetTextExtent(item_path)
        gc.DrawText(item_path, 20, (height - h) / 2)

        # Update 'Release' button state and text color according to item forced
        # flag value
        item_forced = item.IsForced()
        self.Buttons[1].Enable(item_forced)
        self.RefreshButtonsPosition()
        if item_forced:
            gc.SetTextForeground(wx.BLUE)

        # Draw item current value at right side of Viewer
        item_value = item.GetValue()
        w, h = gc.GetTextExtent(item_value)
        gc.DrawText(item_value, width - 40 - w, (height - h) / 2)

        # Draw other Viewer common elements
        self.DrawCommonElements(gc)

        gc.EndDrawing()