Python wx.BufferedDC() Examples

The following are 8 code examples of wx.BufferedDC(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module wx , or try the search function .
Example #1
Source File: squaremap.py    From pyFileFixity with MIT License 5 votes vote down vote up
def UpdateDrawing(self):
        dc = wx.BufferedDC(wx.ClientDC(self), self._buffer)
        self.Draw(dc) 
Example #2
Source File: Bling.py    From BitTorrent with GNU General Public License v3.0 5 votes vote down vote up
def update(self, force=False):
        if not self.IsShown() and not force:
            return
        dc = wx.BufferedDC(wx.ClientDC(self), self.buffer)
        self.draw(dc, size = self.GetClientSize()) 
Example #3
Source File: Main_Dialog.py    From topoflow with MIT License 5 votes vote down vote up
def Plotting_Test(self):

        #--------------------------------------------------------
        # Note:  We may need to save the window's bitmap in a
        #        buffer and refresh it on certain events.
        #        As it stands now, moving the cursor to another
        #        window causes window contents to be lost,
        #        even if we use the Freeze() method.
        #--------------------------------------------------------
        window = self.plot_window
        nx  = self.window_nx
        ny  = self.window_ny
        # win_buffer = self.plot_buffer
        win_buffer = wx.EmptyBitmap(nx,ny)
        #---------------------------------------------
        # Create a device context (don't store them)
        #---------------------------------------------
        dc = wx.BufferedDC(wx.ClientDC(window))
        ## dc = wx.BufferedDC(wx.ClientDC(window), win_buffer)
        ## dc = wx.ClientDC(window)  # (also works)
        ## dc = wx.WindowDC(window)  # (also works)
        pen   = wx.Pen("black", 2, wx.SOLID)
        brush = wx.Brush("white", wx.SOLID)  # (for filling in areas)
        dc.SetPen(pen)
        dc.SetBrush(brush)
        dc.SetBackground(brush)
        dc.Clear()
        #------------------------------------------
        dc.DrawRectangle(0,0,nx,ny)
        dc.DrawLine(0,0,nx,ny)
        dc.DrawCircle(nx/2,ny/2, nx/3)
        # print 'dc.GetSize() =', dc.GetSize()

        ## window.Freeze()   # (see also window.Thaw() )
        ## window.Disable()
        
    #   Plotting_Test()       
    #---------------------------------------------------------------- 
Example #4
Source File: AnimatedWindow.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def UpdateDrawing(self, dummyEvent=None):
        deviceContext = wx.BufferedDC(wx.ClientDC(self), self.dcBuffer)
        self.Draw(deviceContext) 
Example #5
Source File: __init__.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def SetDrawing(self, drawFunc, args):
        self.drawing = drawFunc
        d = GetMonitorDimensions()[self.displayNum]
        self.SetDimensions(d.x, d.y, d.width, d.height)
        self._buffer = wx.EmptyBitmap(d.width, d.height)
        dc = wx.BufferedDC(wx.ClientDC(self), self._buffer)
        self.drawing(dc, *args)
        #self.Refresh(eraseBackground=False)
        wx.Frame.Show(self, True)
        BringHwndToFront(self.GetHandle(), False)
        self.SetCursor(wx.StockCursor(wx.CURSOR_BLANK)) 
Example #6
Source File: LogViewer.py    From OpenPLC_Editor with GNU General Public License v3.0 5 votes vote down vote up
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() 
Example #7
Source File: pyslip.py    From dials with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def Update(self):
        """Causes the canvas to be updated."""

        dc = wx.BufferedDC(wx.ClientDC(self), self.buffer)
        if WX3:
            dc.BeginDrawing()
        dc.Clear()
        self.Draw(dc)
        if WX3:
            dc.EndDrawing() 
Example #8
Source File: DebugVariableTextViewer.py    From OpenPLC_Editor with GNU General Public License v3.0 4 votes vote down vote up
def DrawViewer(self):
        """
        Redraw 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()