本文整理汇总了Python中wx.Brush方法的典型用法代码示例。如果您正苦于以下问题:Python wx.Brush方法的具体用法?Python wx.Brush怎么用?Python wx.Brush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wx
的用法示例。
在下文中一共展示了wx.Brush方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SetBrush
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Brush [as 别名]
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))
示例2: SetUpDraw
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Brush [as 别名]
def SetUpDraw(self, dc, WorldToPixel, ScaleWorldToPixel, HTdc):
"""
Setup for draw
:param `dc`: the dc to draw ???
:param `WorldToPixel`: ???
:param `ScaleWorldToPixel`: ???
:param `HTdc`: ???
"""
dc.SetPen(self.Pen)
dc.SetBrush(self.Brush)
if HTdc and self.HitAble:
HTdc.SetPen(self.HitPen)
HTdc.SetBrush(self.HitBrush)
return ( WorldToPixel(self.XY),
ScaleWorldToPixel(self.WH) )
示例3: _Draw
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Brush [as 别名]
def _Draw(self, dc, WorldToPixel, ScaleWorldToPixel, HTdc=None):
dc.SetPen(self.Pen)
xy = WorldToPixel(self.XY)
if self.Diameter <= 1:
dc.DrawPoint(xy[0], xy[1])
else:
dc.SetBrush(self.Brush)
radius = int(round(self.Diameter/2))
dc.DrawCircle(xy[0],xy[1], radius)
if HTdc and self.HitAble:
HTdc.SetPen(self.HitPen)
if self.Diameter <= 1:
HTdc.DrawPoint(xy[0], xy[1])
else:
HTdc.SetBrush(self.HitBrush)
HTdc.DrawCircle(xy[0],xy[1], radius)
示例4: _makeBitmap
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Brush [as 别名]
def _makeBitmap(self):
width = height = 22
bg = self.GetColour()
if self.HasFlag(CLRP_SHOW_LABEL):
w, h = self.GetTextExtent(bg.GetAsString(wx.C2S_HTML_SYNTAX))
width += w
bmp = wx.Bitmap(width, height)
dc = wx.MemoryDC(bmp)
dc.SetBackground(wx.Brush(self.colour))
dc.Clear()
if self.HasFlag(CLRP_SHOW_LABEL):
from wx.lib.colourutils import BestLabelColour
fg = BestLabelColour(bg)
dc.SetTextForeground(fg)
dc.DrawText(bg.GetAsString(wx.C2S_HTML_SYNTAX),
(width - w)/2, (height - h)/2)
return bmp
#--------------------------------------------------
示例5: draw_background
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Brush [as 别名]
def draw_background(self):
"""
Draw the background box.
If I don't do this, then the background is black.
Could I change wx.EmptyBitmap() so that it defaults to white rather
than black?
"""
# TODO: change the bitmap background to be transparent
c = wx.Colour(200, 230, 230, 0)
c = wx.Colour(255, 255, 255, 0)
pen = wx.Pen(c)
brush = wx.Brush(c)
self.mdc.SetPen(pen)
self.mdc.SetBrush(brush)
self.mdc.DrawRectangle(0, 0, self.dc_w, self.dc_h)
示例6: OnPaint
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Brush [as 别名]
def OnPaint(self, evt):
# this doesnt appear to work at all...
width,height = self.GetSizeTuple()
# get drawing canvas
dc = wx.PaintDC(self)
dc.SetPen(wx.Pen(wx.Colour(0,0,255,255)))
dc.SetBrush(wx.Brush(wx.Colour(0,0,255,220)))
# build rect
size = max(2, (width-10)*self.progress)
rect = wx.Rect(5,8, size ,5)
# draw rect
dc.Clear()
dc.BeginDrawing()
dc.DrawRoundedRectangleRect(rect, 2)
dc.EndDrawing()
示例7: OnPaint
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Brush [as 别名]
def OnPaint(self, evt):
# this doesnt appear to work at all...
width,height = self.GetSizeTuple()
# get drawing shit
dc = wx.PaintDC(self)
dc.SetPen(wx.Pen(wx.Colour(0,0,255,255)))
dc.SetBrush(wx.Brush(wx.Colour(0,0,255,220)))
# build rect
size = max(2, (width-10)*self.progress)
rect = wx.Rect(5,8, size ,5)
# draw rect
dc.Clear()
dc.BeginDrawing()
dc.DrawRoundedRectangleRect(rect, 2)
dc.EndDrawing()
# end wxGlade
示例8: Render
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Brush [as 别名]
def Render(self, cell, dc, state):
position = cell.GetPosition()
for device in self._Devices:
box = self.GetTextExtent(device['name'])
RADIUS = DeviceListRenderer.CORNER_RADIUS
if device['vendor'] == 'nvidia':
color = self._ColorDb.Find('LIME GREEN')
else:
color = self._ColorDb.Find('LIGHT GREY')
dc.SetBrush(wx.Brush(color))
dc.SetPen(wx.TRANSPARENT_PEN)
shadeRect = wx.Rect(
position,
wx.Size(box.GetWidth() + RADIUS*2, box.GetHeight() + RADIUS*2))
dc.DrawRoundedRectangle(shadeRect, RADIUS)
textRect = wx.Rect(
wx.Point(position.x + RADIUS, position.y + RADIUS), box)
self.RenderText(device['name'], 0, textRect, dc, state)
position = wx.Point(
position.x, (position.y + box.GetHeight() + RADIUS*2 + RADIUS))
return True
示例9: Draw
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Brush [as 别名]
def Draw(
self,
dc,
foregroundColour,
backgroundColour,
coverage,
aspectRatio=0,
display=0, # deprecated
):
dc.SetBackground(wx.Brush(backgroundColour))
dc.Clear()
dc.SetPen(wx.Pen(foregroundColour, 1))
dc.SetBrush(wx.Brush(foregroundColour))
dc.SetPen(wx.Pen(foregroundColour, 1))
dc.SetBrush(wx.Brush(foregroundColour))
w, h = dc.GetSizeTuple()
area = (w * h) * coverage / 100
width = height = sqrt(area)
dc.DrawRectangle((w - width) / 2, (h - height) / 2, width, height)
示例10: process_draw
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Brush [as 别名]
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)
示例11: DrawHighlightment
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Brush [as 别名]
def DrawHighlightment(self, dc):
scalex, scaley = dc.GetUserScale()
dc.SetUserScale(1, 1)
dc.SetPen(MiterPen(HIGHLIGHTCOLOR))
dc.SetBrush(wx.Brush(HIGHLIGHTCOLOR))
dc.SetLogicalFunction(wx.AND)
# Draw two rectangles for representing the contact
left_left = (self.Pos.x - 1) * scalex - 2
right_left = (self.Pos.x + self.Size[0] - 2) * scalex - 2
top = (self.Pos.y - 1) * scaley - 2
width = 4 * scalex + 5
height = (self.Size[1] + 3) * scaley + 5
dc.DrawRectangle(left_left, top, width, height)
dc.DrawRectangle(right_left, top, width, height)
dc.SetLogicalFunction(wx.COPY)
dc.SetUserScale(scalex, scaley)
# Adds an highlight to the connection
示例12: DrawHighlightedText
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Brush [as 别名]
def DrawHighlightedText(dc, text, highlights, x, y):
current_pen = dc.GetPen()
dc.SetPen(wx.TRANSPARENT_PEN)
for start, end, highlight_type in highlights:
dc.SetBrush(wx.Brush(highlight_type[0]))
offset_width, _offset_height = dc.GetTextExtent(text[:start[1]])
part = text[start[1]:end[1] + 1]
part_width, part_height = dc.GetTextExtent(part)
dc.DrawRectangle(x + offset_width, y, part_width, part_height)
dc.SetTextForeground(highlight_type[1])
dc.DrawText(part, x + offset_width, y)
dc.SetPen(current_pen)
dc.SetTextForeground(wx.BLACK)
# -------------------------------------------------------------------------------
# Graphic element base class
# -------------------------------------------------------------------------------
示例13: DrawHighlightment
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Brush [as 别名]
def DrawHighlightment(self, dc):
scalex, scaley = dc.GetUserScale()
dc.SetUserScale(1, 1)
pen = MiterPen(HIGHLIGHTCOLOR, 2 * scalex + 5)
pen.SetCap(wx.CAP_BUTT)
dc.SetPen(pen)
dc.SetBrush(wx.Brush(HIGHLIGHTCOLOR))
dc.SetLogicalFunction(wx.AND)
parent_pos = self.ParentBlock.GetPosition()
xstart = parent_pos[0] + self.Pos.x
ystart = parent_pos[1] + self.Pos.y
if self.Direction[0] < 0:
xstart += 1
if self.Direction[1] < 0:
ystart += 1
xend = xstart + CONNECTOR_SIZE * self.Direction[0]
yend = ystart + CONNECTOR_SIZE * self.Direction[1]
dc.DrawLine(round((xstart + self.Direction[0]) * scalex), round((ystart + self.Direction[1]) * scaley),
round(xend * scalex), round(yend * scaley))
dc.SetLogicalFunction(wx.COPY)
dc.SetUserScale(scalex, scaley)
# Adds an highlight to the connector
示例14: OnPaint
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Brush [as 别名]
def OnPaint(self, event):
dc = wx.PaintDC(self)
w, h = self.GetClientSizeTuple()
br = wx.Brush(self.GetBackgroundColour())
dc.SetBrush(br)
dc.DrawRectangle(0, 0, w, h)
# Custom "exit fullscreen" button for our tab bar. Used so that we have
# full control over the button's size.
示例15: draw
# 需要导入模块: import wx [as 别名]
# 或者: from wx import Brush [as 别名]
def draw(self, dc):
color = 'green'
if not self.is_finished:
color = 'yellow'
if self.is_failed:
color = 'red'
dc.SetBrush(wx.Brush(color, wx.SOLID))
dc.DrawCircle(self.x, self.y, 20)