Python wx.BLACK_PEN Examples

The following are 8 code examples of wx.BLACK_PEN(). 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: custom_widget.py    From wxGlade with MIT License 6 votes vote down vote up
def on_paint(self, event):
        dc = wx.PaintDC(self.widget)
        dc.SetBrush(wx.WHITE_BRUSH)
        dc.SetPen(wx.BLACK_PEN)
        dc.SetBackground(wx.WHITE_BRUSH)
        dc.Clear()
        w, h = self.widget.GetClientSize()
        dc.DrawLine(0, 0, w, h)
        dc.DrawLine(w, 0, 0, h)
        text = _('Custom Widget: %s') % self.instance_class
        tw, th = dc.GetTextExtent(text)
        x = (w - tw)//2
        y = (h - th)//2
        dc.SetPen(wx.ThePenList.FindOrCreatePen(wx.BLACK, 0, wx.TRANSPARENT))
        dc.DrawRectangle(x-1, y-1, tw+2, th+2)
        dc.DrawText(text, x, y) 
Example #2
Source File: Widget.py    From meerk40t with MIT License 6 votes vote down vote up
def process_draw(self, gc):
        if self.scene.device.draw_mode & DRAW_MODE_GRID != 0:
            return
        device = self.scene.device
        if device is not None:
            wmils = device.bed_width * MILS_IN_MM
            hmils = device.bed_height * MILS_IN_MM
        else:
            wmils = 320 * MILS_IN_MM
            hmils = 220 * MILS_IN_MM
        background = self.background
        if background is None:
            gc.SetBrush(wx.WHITE_BRUSH)
            gc.DrawRectangle(0, 0, wmils, hmils)
        elif isinstance(background, int):
            gc.SetBrush(wx.Brush(wx.Colour(swizzlecolor(background))))
            gc.DrawRectangle(0, 0, wmils, hmils)
        else:
            gc.DrawBitmap(background, 0, 0, wmils, hmils)

        if self.grid is None:
            self.calculate_grid()
        starts, ends = self.grid
        gc.SetPen(wx.BLACK_PEN)
        gc.StrokeLineSegments(starts, ends) 
Example #3
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 #4
Source File: CustomToolTip.py    From OpenPLC_Editor with GNU General Public License v3.0 5 votes vote down vote up
def OnPaint(self, event):
        """
        Callback for Paint Event
        @param event: Paint event
        """
        # Get buffered paint DC for tool tip
        dc = wx.AutoBufferedPaintDC(self)
        dc.Clear()

        # Set DC drawing style
        dc.SetPen(wx.BLACK_PEN)
        dc.SetBrush(wx.Brush(wx.Colour(255, 238, 170)))
        dc.SetFont(self.Font)

        # Draw Tool tip
        dc.BeginDrawing()
        tip_width, tip_height = self.GetToolTipSize()

        # Draw background rectangle
        dc.DrawRectangle(0, 0, tip_width, tip_height)

        # Draw tool tip text
        line_offset = 0
        for line in self.Tip:
            dc.DrawText(line, 2, line_offset + 2)
            _line_width, line_height = dc.GetTextExtent(line)
            line_offset += line_height

        dc.EndDrawing()

        event.Skip() 
Example #5
Source File: OLVPrinter.py    From bookhub with MIT License 5 votes vote down vote up
def run(self):
            printer = OLVPrinter(self.olv, "First ObjectListView Report")
            printer.ReportFormat = ReportFormat.Normal()

            #fmt.PageHeader.Font = wx.FFont(36, wx.FONTFAMILY_SWISS, face="Gill Sans")
            #fmt.PageHeader.Add(BackgroundDecoration(wx.BLUE))
            #fmt.PageHeader.Add(LineDecoration(side=Decoration.TOP, pen=wx.Pen(wx.RED, 5), space=0))
            #fmt.PageHeader.Add(LineDecoration(pen=wx.BLACK_PEN, space=0))
            #
            #fmt.PageFooter.Font = wx.FFont(12, wx.FONTFAMILY_SWISS, face="Gill Sans")
            #fmt.PageFooter.Add(BackgroundDecoration(wx.GREEN))
            #fmt.PageFooter.Add(LineDecoration(pen=wx.Pen(wx.BLUE, 5), space=0))
            #fmt.PageFooter.Add(LineDecoration(side=Decoration.TOP, pen=wx.RED_PEN, space=0))

            printer.PrintPreview(self) 
Example #6
Source File: charmapdlg.py    From trelby with GNU General Public License v2.0 4 votes vote down vote up
def OnPaint(self, event):
        dc = wx.BufferedPaintDC(self, self.screenBuf)

        size = self.GetClientSize()
        dc.SetBrush(wx.WHITE_BRUSH)
        dc.SetPen(wx.WHITE_PEN)
        dc.DrawRectangle(0, 0, size.width, size.height)

        dc.SetPen(wx.BLACK_PEN)
        dc.SetTextForeground(wx.BLACK)

        for y in range(self.rows + 1):
            util.drawLine(dc, self.offset, self.offset + y * self.cellSize,
                          self.cols * self.cellSize + 1, 0)

        for x in range(self.cols + 1):
            util.drawLine(dc, self.offset + x * self.cellSize,
                self.offset, 0, self.rows * self.cellSize)

        dc.SetFont(self.normalFont)

        for y in range(self.rows):
            for x in range(self.cols):
                i = y * self.cols + x
                if i < len(self.chars):
                    util.drawText(dc, self.chars[i],
                        x * self.cellSize + self.offset + self.cellSize // 2 + 1,
                        y * self.cellSize + self.offset + self.cellSize // 2 + 1,
                        util.ALIGN_CENTER, util.VALIGN_CENTER)

        y = self.offset + self.rows * self.cellSize
        pad = 5

        if self.selected:
            code = ord(self.selected)

            self.drawCharBox(dc, "Selected:", self.selected, self.offset,
                             y + pad, 75)

            c = util.upper(self.selected)
            if c == self.selected:
                c = util.lower(self.selected)
                if c == self.selected:
                    c = None

            if c:
                self.drawCharBox(dc, "Opposite case:", c, self.offset + 150,
                                 y + pad, 110)

            dc.SetFont(self.smallFont)
            dc.DrawText("Character code: %d" % code, 360, y + pad)

            if code == 32:
                dc.DrawText("Normal space", 360, y + pad + 30)
            elif code == 160:
                dc.DrawText("Non-breaking space", 360, y + pad + 30)

        else:
            dc.SetFont(self.smallFont)
            dc.DrawText("Click on a character to select it.", self.offset,
                        y + pad) 
Example #7
Source File: Widget.py    From meerk40t with MIT License 4 votes vote down vote up
def process_draw(self, gc):
        if self.scene.device.draw_mode & DRAW_MODE_GUIDES != 0:
            return
        gc.SetPen(wx.BLACK_PEN)
        w, h = gc.Size
        p = self.scene.device.device_root
        scaled_conversion = p.units_convert * self.scene.widget_root.scene_widget.matrix.value_scale_x()
        if scaled_conversion == 0:
            return

        wpoints = w / 15.0
        hpoints = h / 15.0
        points = min(wpoints, hpoints)
        # tweak the scaled points into being useful.
        # points = scaled_conversion * round(points / scaled_conversion * 10.0) / 10.0
        points = scaled_conversion * float('{:.1g}'.format(points / scaled_conversion))
        sx, sy = self.scene.convert_scene_to_window([0, 0])
        if points == 0:
            return
        offset_x = sx % points
        offset_y = sy % points

        starts = []
        ends = []
        x = offset_x
        length = 50
        font = wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD)
        gc.SetFont(font, wx.BLACK)
        while x < w:
            starts.append((x, 0))
            ends.append((x, length))

            starts.append((x, h))
            ends.append((x, h-length))

            mark_point = (x - sx) / scaled_conversion
            if round(mark_point * 1000) == 0:
                mark_point = 0.0  # prevents -0
            gc.DrawText("%g %s" % (mark_point, p.units_name), x, 0, -tau / 4)
            x += points

        y = offset_y
        while y < h:
            starts.append((0, y))
            ends.append((length, y))

            starts.append((w, y))
            ends.append((w-length, y))

            mark_point = (y - sy) / scaled_conversion
            if round(mark_point * 1000) == 0:
                mark_point = 0.0  # prevents -0
            gc.DrawText("%g %s" % (mark_point + 0, p.units_name), 0, y + 0)
            y += points
        gc.StrokeLineSegments(starts, ends) 
Example #8
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)


#======================================================================