Python wx.TRANSPARENT_BRUSH Examples

The following are 24 code examples of wx.TRANSPARENT_BRUSH(). 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: backend_wx.py    From twitter-stock-recommendation with MIT License 6 votes vote down vote up
def draw_rubberband(self, x0, y0, x1, y1):
            dc = wx.ClientDC(self.canvas)
            # this would be required if the Canvas is a ScrolledWindow,
            # which is not the case for now
            # self.PrepareDC(dc)

            # delete old rubberband
            if self._rect:
                self.remove_rubberband(dc)

            # draw new rubberband
            dc.SetPen(wx.Pen(wx.BLACK, 1, wx.SOLID))
            dc.SetBrush(wx.TRANSPARENT_BRUSH)
            self._rect = (x0, self.canvas._height-y0, x1-x0, -y1+y0)
            if wxc.is_phoenix:
                dc.DrawRectangle(self._rect)
            else:
                dc.DrawRectangleRect(self._rect) 
Example #2
Source File: ListCtrlPrinter.py    From bookhub with MIT License 6 votes vote down vote up
def DrawDecoration(self, dc, bounds, block):
        """
        Draw this decoration
        """
        rect = self._CalculateRect(bounds)

        if self.color:
            if self.toColor is None:
                dc.SetPen(wx.TRANSPARENT_PEN)
                dc.SetBrush(wx.Brush(self.color))
                dc.DrawRectangle(*rect)
            else:
                dc.GradientFillLinear(wx.Rect(*rect), self.color, self.toColor)

        if self.pen:
            dc.SetPen(self.pen)
            dc.SetBrush(wx.TRANSPARENT_BRUSH)
            dc.DrawRectangle(*rect) 
Example #3
Source File: OLVPrinter.py    From bookhub with MIT License 6 votes vote down vote up
def DrawDecoration(self, dc, bounds, block):
        """
        Draw this decoration
        """
        if self.pen is None:
            return
        # We want to draw our decoration within the given bounds. Fat pens are drawn half
        # either side of the coords, so we contract our coords so that fat pens don't
        # cause drawing outside our bounds.
        if self.pen.GetWidth() > 1:
            rect = RectUtils.InsetBy(bounds, self.pen.GetWidth()/2)
        else:
            rect = bounds
        dc.SetPen(self.pen)
        dc.SetBrush(wx.TRANSPARENT_BRUSH)
        if self.corner:
            dc.DrawRoundedRectangle(rect[0], rect[1], rect[2], rect[3], self.corner)
        else:
            dc.DrawRectangle(*rect)

#---------------------------------------------------------------------------- 
Example #4
Source File: PouInstanceVariablesPanel.py    From OpenPLC_Editor with GNU General Public License v3.0 6 votes vote down vote up
def PaintItem(self, item, dc, level, align):
        CT.CustomTreeCtrl.PaintItem(self, item, dc, level, align)

        rightimages = item.GetRightImages()
        if len(rightimages) > 0:
            images_bbx = self.GetItemRightImagesBBox(item)
            r_image_w, _r_image_h = self._imageListRight.GetSize(rightimages[0])

            dc.SetBrush(wx.TRANSPARENT_BRUSH)
            dc.SetPen(wx.TRANSPARENT_PEN)

            dc.DrawRectangle(images_bbx.x, images_bbx.y,
                             images_bbx.width, images_bbx.height)
            x_pos = images_bbx.x + 4
            for r_image in rightimages:
                self._imageListRight.Draw(
                    r_image, dc, x_pos, images_bbx.y + 4,
                    wx.IMAGELIST_DRAW_TRANSPARENT)
                x_pos += r_image_w + 4 
Example #5
Source File: LD_Objects.py    From OpenPLC_Editor with GNU General Public License v3.0 6 votes vote down vote up
def DrawHighlightment(self, dc):
        scalex, scaley = dc.GetUserScale()
        dc.SetUserScale(1, 1)
        dc.SetPen(MiterPen(HIGHLIGHTCOLOR, (3 * scalex + 5), wx.SOLID))
        dc.SetBrush(wx.TRANSPARENT_BRUSH)
        dc.SetLogicalFunction(wx.AND)
        # Draw a two circle arcs for representing the coil
        dc.DrawEllipticArc(round(self.Pos.x * scalex),
                           round((self.Pos.y - int(self.Size[1] * (sqrt(2) - 1.) / 2.) + 1) * scaley),
                           round(self.Size[0] * scalex),
                           round((int(self.Size[1] * sqrt(2)) - 1) * scaley),
                           135, 225)
        dc.DrawEllipticArc(round(self.Pos.x * scalex),
                           round((self.Pos.y - int(self.Size[1] * (sqrt(2) - 1.) / 2.) + 1) * scaley),
                           round(self.Size[0] * scalex),
                           round((int(self.Size[1] * sqrt(2)) - 1) * scaley),
                           -45, 45)
        dc.SetLogicalFunction(wx.COPY)
        dc.SetUserScale(scalex, scaley)

    # Adds an highlight to the connection 
Example #6
Source File: Widget.py    From meerk40t with MIT License 6 votes vote down vote up
def process_draw(self, gc):
        device = self.scene.device
        if device.draw_mode & DRAW_MODE_RETICLE == 0:
            # Draw Reticle
            gc.SetPen(wx.RED_PEN)
            gc.SetBrush(wx.TRANSPARENT_BRUSH)
            try:
                x = device.current_x
                y = device.current_y
                if x is None or y is None:
                    x = 0
                    y = 0
                x, y = self.scene.convert_scene_to_window([x, y])
                gc.DrawEllipse(x - 5, y - 5, 10, 10)
            except AttributeError:
                pass 
Example #7
Source File: FCObjects.py    From wafer_map with GNU General Public License v3.0 6 votes vote down vote up
def SetBrush(self, FillColor, FillStyle):
        """
        Set the brush for this DrawObject
        
        :param `FillColor`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetColor`
         for valid entries
        :param `FillStyle`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetFillStyle`
         for valid entries
        """
        if FillColor is None or FillStyle is None:
            self.Brush = wx.TRANSPARENT_BRUSH
            ##fixme: should I really re-set the style?
            self.FillStyle = "Transparent"
        else:
            self.Brush = self.BrushList.setdefault(
                (FillColor, FillStyle),
                wx.Brush(FillColor, self.FillStyleList[FillStyle]))
            #print("Setting Brush, BrushList length:", len(self.BrushList)) 
Example #8
Source File: LaserRender.py    From meerk40t with MIT License 5 votes vote down vote up
def set_brush(self, gc, fill):
        c = fill
        if c is not None and c != 'none':
            swizzle_color = swizzlecolor(c)
            self.color.SetRGB(swizzle_color)  # wx has BBGGRR
            self.brush.SetColour(self.color)
            gc.SetBrush(self.brush)
        else:
            gc.SetBrush(wx.TRANSPARENT_BRUSH) 
Example #9
Source File: Viewer.py    From OpenPLC_Editor with GNU General Public License v3.0 5 votes vote down vote up
def RefreshScaling(self, refresh=True):
        properties = self.Controler.GetProjectProperties(self.Debug)
        scaling = properties["scaling"][self.CurrentLanguage]
        if scaling[0] != 0 and scaling[1] != 0:
            self.Scaling = scaling
            if self.DrawGrid:
                width = max(2, int(scaling[0] * self.ViewScale[0]))
                height = max(2, int(scaling[1] * self.ViewScale[1]))
                bitmap = wx.EmptyBitmap(width, height)
                dc = wx.MemoryDC(bitmap)
                dc.SetBackground(wx.Brush(self.Editor.GetBackgroundColour()))
                dc.Clear()
                dc.SetPen(MiterPen(wx.Colour(180, 180, 180)))
                dc.DrawPoint(0, 0)
                self.GridBrush = wx.BrushFromBitmap(bitmap)
            else:
                self.GridBrush = wx.TRANSPARENT_BRUSH
        else:
            self.Scaling = None
            self.GridBrush = wx.TRANSPARENT_BRUSH
        page_size = properties["pageSize"]
        if page_size != (0, 0):
            self.PageSize = map(int, page_size)
            self.PagePen = MiterPen(wx.Colour(180, 180, 180))
        else:
            self.PageSize = None
            self.PagePen = wx.TRANSPARENT_PEN
        if refresh:
            self.RefreshVisibleElements()
            self.Editor.Refresh(False)

    # -------------------------------------------------------------------------------
    #                          Refresh functions
    # ------------------------------------------------------------------------------- 
Example #10
Source File: RubberBand.py    From OpenPLC_Editor with GNU General Public License v3.0 5 votes vote down vote up
def DrawBoundingBoxes(self, bboxes, dc=None):
        """
        Draw a list of bounding box on Viewer in the order given using XOR
        logical function
        @param bboxes: List of bounding boxes to draw on viewer
        @param dc: Device Context of Viewer (default None)
        """
        # Get viewer Device Context if not given
        if dc is None:
            dc = self.Viewer.GetLogicalDC()

        # Save current viewer scale factors before resetting them in order to
        # avoid rubberband pen to be scaled
        scalex, scaley = dc.GetUserScale()
        dc.SetUserScale(1, 1)

        # Set DC drawing style
        dc.SetPen(wx.Pen(wx.WHITE, style=wx.DOT))
        dc.SetBrush(wx.TRANSPARENT_BRUSH)
        dc.SetLogicalFunction(wx.XOR)

        # Draw the bounding boxes using viewer scale factor
        for bbox in bboxes:
            if bbox is not None:
                dc.DrawRectangle(
                    bbox.x * scalex, bbox.y * scaley,
                    bbox.width * scalex, bbox.height * scaley)

        dc.SetLogicalFunction(wx.COPY)

        # Restore Viewer scale factor
        dc.SetUserScale(scalex, scaley) 
Example #11
Source File: __init__.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def Draw(
        self,
        dc,
        aspectRatioIndex=0
    ):
        dc.SetBackground(wx.Brush("black"))
        dc.Clear()
        w, h = dc.GetSizeTuple()
        gc = wx.GraphicsContext.Create(dc)
        gc.PushState()
        gc.SetPen(wx.Pen("white", 3.0))
        gc.SetBrush(wx.TRANSPARENT_BRUSH)

        aspectRatio, isCCIR601 = ASPECT_RATIOS[aspectRatioIndex]
        if aspectRatio is None:
            gc.Scale(h / 1000.0, h / 1000.0)
            gc.Translate(1000.0 * (w * 1.0 / h) / 2, 500)
        elif w > h:
            gc.Scale(w / (aspectRatio * 1000.0), h / 1000.0)
            gc.Translate(500 * aspectRatio, 500)
        gc.DrawEllipse(-450, -450, 900, 900)
        gc.PopState()
        dc.SetPen(wx.Pen("white", 2))
        if isCCIR601:
            offset = int(round(w * 8.0 / 720.0))
            dc.SetBrush(wx.GREY_BRUSH)
            dc.DrawRectangle(1, 1, offset-1, h-1)
            dc.DrawRectangle(w-offset, 1, offset, h-1)

        dc.SetBrush(wx.TRANSPARENT_BRUSH)
        dc.DrawRectangle(1, 1, w-1, h-1)
        dc.DrawLine(0, h/2, w, h/2)
        dc.DrawLine(w/2, 0, w/2, h) 
Example #12
Source File: backend_wx.py    From CogAlg with MIT License 5 votes vote down vote up
def draw_rubberband(self, x0, y0, x1, y1):
            dc = wx.ClientDC(self.canvas)
            # this would be required if the Canvas is a ScrolledWindow,
            # which is not the case for now
            # self.PrepareDC(dc)

            # delete old rubberband
            if self._rect:
                self.remove_rubberband(dc)

            # draw new rubberband
            dc.SetPen(wx.Pen(wx.BLACK, 1, wx.SOLID))
            dc.SetBrush(wx.TRANSPARENT_BRUSH)
            self._rect = (x0, self.canvas._height-y0, x1-x0, -y1+y0)
            dc.DrawRectangle(self._rect) 
Example #13
Source File: backend_wx.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def draw_rubberband(self, x0, y0, x1, y1):
            dc = wx.ClientDC(self.canvas)
            # this would be required if the Canvas is a ScrolledWindow,
            # which is not the case for now
            # self.PrepareDC(dc)

            # delete old rubberband
            if self._rect:
                self.remove_rubberband(dc)

            # draw new rubberband
            dc.SetPen(wx.Pen(wx.BLACK, 1, wx.SOLID))
            dc.SetBrush(wx.TRANSPARENT_BRUSH)
            self._rect = (x0, self.canvas._height-y0, x1-x0, -y1+y0)
            dc.DrawRectangle(self._rect) 
Example #14
Source File: params.py    From admin4 with Apache License 2.0 5 votes vote down vote up
def OnPaintButton(self, evt):
        dc = wx.PaintDC(self.button)
        dc.SetBrush(wx.TRANSPARENT_BRUSH)
        if self.IsEnabled(): dc.SetPen(wx.BLACK_PEN)
        else: dc.SetPen(wx.GREY_PEN)
        size = self.button.GetSize()
        dc.DrawRectangle(0, 0, size.width, size.height) 
Example #15
Source File: CustomWidgets.py    From BitTorrent with GNU General Public License v3.0 5 votes vote down vote up
def draw(self, dc, size):
        srect = wx.Rect(0, 0, size.width, size.height)
        self.draw_bar(dc, srect)

        # dear god, I hope it's smooth
        if self.gauge_theme["smooth"]:
            dc.SetClippingRegion(srect.x, srect.y, srect.width, srect.height)
            _ScaleBlit(self.smoother, dc,
                       wx.Rect(0, 0, srect.width, srect.height))

        # top-line
        if self.top_line and self.percent is not None:
            dc.SetBrush(wx.TRANSPARENT_BRUSH)
            dc.SetPen(wx.Pen(self.line_color))
            line_width = 1
            # top:
            line_position = 0
            # middle:
            #line_position = (srect.height) // 2
            # bottom:
            #line_position = srect.height - line_width
            dc.DrawRectangle(srect.x, line_position,
                             srect.width * self.percent, line_width)
            dc.SetPen(wx.Pen(self.border_color))
            dc.DrawRectangle(srect.x + srect.width * self.percent, line_position,
                             srect.width, line_width) 
Example #16
Source File: CustomWidgets.py    From BitTorrent with GNU General Public License v3.0 5 votes vote down vote up
def OnPaint(self, event):
        dc = wx.PaintDC(self)
        rect = self.GetClientRect()

        if self.border:
            dc.SetPen(wx.Pen(self.border_color))
            dc.SetBrush(wx.TRANSPARENT_BRUSH)
            dc.DrawRectangle(0, 0, rect.width, rect.height)
            rect = wx.Rect(rect.x + 1, rect.y + 1,
                           rect.width - 2, rect.height - 2)

        _ScaleBlit(self.buffer, dc, rect) 
Example #17
Source File: backend_wx.py    From python3_ios with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def draw_rubberband(self, x0, y0, x1, y1):
            dc = wx.ClientDC(self.canvas)
            # this would be required if the Canvas is a ScrolledWindow,
            # which is not the case for now
            # self.PrepareDC(dc)

            # delete old rubberband
            if self._rect:
                self.remove_rubberband(dc)

            # draw new rubberband
            dc.SetPen(wx.Pen(wx.BLACK, 1, wx.SOLID))
            dc.SetBrush(wx.TRANSPARENT_BRUSH)
            self._rect = (x0, self.canvas._height-y0, x1-x0, -y1+y0)
            dc.DrawRectangle(self._rect) 
Example #18
Source File: backend_wx.py    From GraphicDesignPatternByPython with MIT License 5 votes vote down vote up
def draw_rubberband(self, x0, y0, x1, y1):
            dc = wx.ClientDC(self.canvas)
            # this would be required if the Canvas is a ScrolledWindow,
            # which is not the case for now
            # self.PrepareDC(dc)

            # delete old rubberband
            if self._rect:
                self.remove_rubberband(dc)

            # draw new rubberband
            dc.SetPen(wx.Pen(wx.BLACK, 1, wx.SOLID))
            dc.SetBrush(wx.TRANSPARENT_BRUSH)
            self._rect = (x0, self.canvas._height-y0, x1-x0, -y1+y0)
            dc.DrawRectangle(self._rect) 
Example #19
Source File: backend_wx.py    From Mastering-Elasticsearch-7.0 with MIT License 5 votes vote down vote up
def draw_rubberband(self, x0, y0, x1, y1):
            dc = wx.ClientDC(self.canvas)
            # this would be required if the Canvas is a ScrolledWindow,
            # which is not the case for now
            # self.PrepareDC(dc)

            # delete old rubberband
            if self._rect:
                self.remove_rubberband(dc)

            # draw new rubberband
            dc.SetPen(wx.Pen(wx.BLACK, 1, wx.SOLID))
            dc.SetBrush(wx.TRANSPARENT_BRUSH)
            self._rect = (x0, self.canvas._height-y0, x1-x0, -y1+y0)
            dc.DrawRectangle(self._rect) 
Example #20
Source File: FCObjects.py    From wafer_map with GNU General Public License v3.0 5 votes vote down vote up
def SetBrushes(self):
        """Set the Brushes."""
        self.Brushes = []
        for FillColor, FillStyle in zip(self.FillColors, self.FillStyles):
            if FillColor is None or FillStyle is None:
                self.Brush = wx.TRANSPARENT_BRUSH
            else:
                self.Brushes.append(self.BrushList.setdefault( (FillColor, FillStyle),
                                                               wx.Brush( FillColor, self.FillStyleList[FillStyle] )
                                                              )
                                    ) 
Example #21
Source File: FCObjects.py    From wafer_map with GNU General Public License v3.0 5 votes vote down vote up
def SetHitBrush(self, HitColor):
        """
        Set the brush used for hit test, do not call directly.
        
        :param `HitColor`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetColor`
        
        """
        if not self.HitFill:
            self.HitBrush = wx.TRANSPARENT_BRUSH
        else:
            self.HitBrush = self.BrushList.setdefault(
                (HitColor,"solid"),
                wx.Brush(HitColor, self.FillStyleList["Solid"])) 
Example #22
Source File: IDEFrame.py    From OpenPLC_Editor with GNU General Public License v3.0 4 votes vote down vote up
def OnPrintPage(self, page):
        dc = self.GetDC()
        dc.SetBackground(wx.WHITE_BRUSH)
        dc.Clear()
        dc.SetUserScale(1.0, 1.0)
        dc.SetDeviceOrigin(0, 0)
        dc.printing = not self.Preview

        # Get the size of the DC in pixels
        ppiPrinterX, ppiPrinterY = self.GetPPIPrinter()
        pw, ph = self.GetPageSizePixels()
        dw, dh = dc.GetSizeTuple()
        Xscale = (dw * ppiPrinterX) / (pw * 25.4)
        Yscale = (dh * ppiPrinterY) / (ph * 25.4)

        fontsize = self.FontSize * Yscale

        margin_left = self.Margins[0].x * Xscale
        margin_top = self.Margins[0].y * Yscale
        area_width = dw - self.Margins[1].x * Xscale - margin_left
        area_height = dh - self.Margins[1].y * Yscale - margin_top

        dc.SetPen(MiterPen(wx.BLACK))
        dc.SetBrush(wx.TRANSPARENT_BRUSH)
        dc.DrawRectangle(margin_left, margin_top, area_width, area_height)

        dc.SetFont(wx.Font(fontsize, wx.DEFAULT, wx.NORMAL, wx.NORMAL))
        dc.SetTextForeground(wx.BLACK)
        block_name = " - ".join(self.Viewer.GetTagName().split("::")[1:])
        _text_width, text_height = dc.GetTextExtent(block_name)
        dc.DrawText(block_name, margin_left, margin_top - text_height - self.TextMargin)
        dc.DrawText(_("Page: %d") % page, margin_left, margin_top + area_height + self.TextMargin)

        # Calculate the position on the DC for centering the graphic
        posX = area_width * ((page - 1) % self.PageGrid[0])
        posY = area_height * ((page - 1) // self.PageGrid[0])

        scaleX = area_width / self.PageSize[0]
        scaleY = area_height / self.PageSize[1]
        scale = min(scaleX, scaleY)

        # Set the scale and origin
        dc.SetDeviceOrigin(-posX + margin_left, -posY + margin_top)
        dc.SetClippingRegion(posX, posY, self.PageSize[0] * scale, self.PageSize[1] * scale)
        dc.SetUserScale(scale, scale)

        self.Viewer.DoDrawing(dc, True)

        return True 
Example #23
Source File: OLVPrinter.py    From bookhub with MIT License 4 votes vote down vote up
def DrawSelf(self, dc, bounds):
        """
        Do the actual work of rendering this block.
        """
        cellFmt = self.GetFormat()
        cellPadding = self._CalculateCellPadding(cellFmt)
        combined = self.GetCombinedLists()

        # Calculate cell boundaries
        cell = list(bounds)
        cell[2] = 0
        for x in combined:
            RectUtils.SetLeft(cell, RectUtils.Right(cell))
            RectUtils.SetWidth(cell, x.cellWidth + cellPadding[0] + cellPadding[2])
            x.cell = list(cell)
            #dc.SetPen(wx.BLACK_PEN)
            #dc.DrawRectangle(*cell)

        # Draw each cell
        font = self.GetFont()
        for x in combined:
            cellBounds = RectUtils.InsetRect(x.cell, cellPadding)
            self.DrawText(dc, x.text, cellBounds, font, x.align, x.image)
            #dc.SetPen(wx.RED_PEN)
            #dc.DrawRectangle(*cellBounds)

        if cellFmt.GridPen and combined:
            dc.SetPen(cellFmt.GridPen)
            dc.SetBrush(wx.TRANSPARENT_BRUSH)

            top = RectUtils.Top(combined[0].cell)
            bottom = RectUtils.Bottom(combined[0].cell)

            # Draw the interior dividers
            for x in combined[:-1]:
                right = RectUtils.Right(x.cell)
                dc.DrawLine(right, top, right, bottom)

            # Draw the surrounding frame
            left = RectUtils.Left(combined[0].cell)
            right = RectUtils.Right(combined[-1].cell)
            dc.DrawRectangle(left, top, right-left, bottom-top)


#====================================================================== 
Example #24
Source File: ListCtrlPrinter.py    From bookhub with MIT License 4 votes vote down vote up
def DrawSelf(self, dc, bounds):
        """
        Do the actual work of rendering this block.
        """
        cellFmt = self.GetFormat()
        cellPadding = cellFmt.CalculateCellPadding()
        combined = self.GetCombinedLists()

        # Calculate cell boundaries
        cell = list(bounds)
        RectUtils.SetWidth(cell, 0)
        for x in combined:
            RectUtils.SetLeft(cell, RectUtils.Right(cell))
            RectUtils.SetWidth(cell, x.cellWidth)
            x.cell = list(cell)

        # Draw each cell
        font = self.GetFont()
        for x in combined:
            cellBounds = RectUtils.InsetRect(x.cell, cellPadding)
            self.DrawText(dc, x.text, cellBounds, font, x.align, imageIndex=x.image,
                          canWrap=cellFmt.CanWrap, listCtrl=self.GetListCtrl())

        if cellFmt.GridPen and combined:
            dc.SetPen(cellFmt.GridPen)
            dc.SetBrush(wx.TRANSPARENT_BRUSH)

            top = RectUtils.Top(bounds)
            bottom = RectUtils.Bottom(bounds)

            # Draw the interior dividers
            for x in combined[:-1]:
                right = RectUtils.Right(x.cell)
                dc.DrawLine(right, top, right, bottom)

            # Draw the surrounding frame
            left = RectUtils.Left(combined[0].cell)
            right = RectUtils.Right(combined[-1].cell)
            dc.DrawRectangle(left, top, right-left, bottom-top)


#----------------------------------------------------------------------------