本文整理汇总了Python中wx.GCDC属性的典型用法代码示例。如果您正苦于以下问题:Python wx.GCDC属性的具体用法?Python wx.GCDC怎么用?Python wx.GCDC使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类wx
的用法示例。
在下文中一共展示了wx.GCDC属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PrintPage
# 需要导入模块: import wx [as 别名]
# 或者: from wx import GCDC [as 别名]
def PrintPage(self, dc, pageNumber):
"""
Print the given page on the given device context.
"""
#try:
# pdc = wx.GCDC(dc)
#except:
# pdc = dc
pdc = dc
# If the request page isn't next in order, we have to restart
# the printing process and advance until we reach the desired page
if pageNumber != self.currentPage + 1:
print "Skipping pages..."
self.StartPrinting()
for i in range(1, pageNumber):
self.PrintOnePage(pdc, i)
dc.Clear()
print "...finished skipping."
return self.PrintOnePage(pdc, pageNumber)
示例2: draw_rubberband
# 需要导入模块: import wx [as 别名]
# 或者: from wx import GCDC [as 别名]
def draw_rubberband(self, x0, y0, x1, y1):
# Use an Overlay to draw a rubberband-like bounding box.
if self.wxoverlay is None:
self.wxoverlay = wx.Overlay()
dc = wx.ClientDC(self.canvas)
odc = wx.DCOverlay(self.wxoverlay, dc)
odc.Clear()
dc = wx.GCDC(dc)
height = self.canvas.figure.bbox.height
y1 = height - y1
y0 = height - y0
if y1 < y0:
y0, y1 = y1, y0
if x1 < x0:
x0, x1 = x1, x0
w = x1 - x0
h = y1 - y0
rect = wx.Rect(x0, y0, w, h)
rubberBandColor = '#C0C0FF' # or load from config?
# Set a pen for the border
color = wx.Colour(rubberBandColor)
dc.SetPen(wx.Pen(color, 1))
# use the same color, plus alpha for the brush
r, g, b, a = color.Get(True)
color.Set(r, g, b, 0x60)
dc.SetBrush(wx.Brush(color))
dc.DrawRectangle(rect)
示例3: draw_rubberband
# 需要导入模块: import wx [as 别名]
# 或者: from wx import GCDC [as 别名]
def draw_rubberband(self, event, x0, y0, x1, y1):
# Use an Overlay to draw a rubberband-like bounding box.
dc = wx.ClientDC(self.canvas)
odc = wx.DCOverlay(self.wxoverlay, dc)
odc.Clear()
# Mac's DC is already the same as a GCDC, and it causes
# problems with the overlay if we try to use an actual
# wx.GCDC so don't try it.
if 'wxMac' not in wx.PlatformInfo:
dc = wx.GCDC(dc)
height = self.canvas.figure.bbox.height
y1 = height - y1
y0 = height - y0
if y1<y0: y0, y1 = y1, y0
if x1<y0: x0, x1 = x1, x0
w = x1 - x0
h = y1 - y0
rect = wx.Rect(x0, y0, w, h)
rubberBandColor = '#C0C0FF' # or load from config?
# Set a pen for the border
color = wx.NamedColour(rubberBandColor)
dc.SetPen(wx.Pen(color, 1))
# use the same color, plus alpha for the brush
r, g, b = color.Get()
color.Set(r,g,b, 0x60)
dc.SetBrush(wx.Brush(color))
dc.DrawRectangleRect(rect)
示例4: draw_rubberband
# 需要导入模块: import wx [as 别名]
# 或者: from wx import GCDC [as 别名]
def draw_rubberband(self, x0, y0, x1, y1):
# Use an Overlay to draw a rubberband-like bounding box.
if self.wxoverlay is None:
self.wxoverlay = wx.Overlay()
dc = wx.ClientDC(self.canvas)
odc = wx.DCOverlay(self.wxoverlay, dc)
odc.Clear()
dc = wx.GCDC(dc)
height = self.canvas.figure.bbox.height
y1 = height - y1
y0 = height - y0
if y1 < y0:
y0, y1 = y1, y0
if x1 < x0:
x0, x1 = x1, x0
w = x1 - x0
h = y1 - y0
rect = wx.Rect(x0, y0, w, h)
rubberBandColor = '#C0C0FF' # or load from config?
# Set a pen for the border
color = wxc.NamedColour(rubberBandColor)
dc.SetPen(wx.Pen(color, 1))
# use the same color, plus alpha for the brush
r, g, b, a = color.Get(True)
color.Set(r, g, b, 0x60)
dc.SetBrush(wx.Brush(color))
if wxc.is_phoenix:
dc.DrawRectangle(rect)
else:
dc.DrawRectangleRect(rect)
示例5: _draw_ring_layer
# 需要导入模块: import wx [as 别名]
# 或者: from wx import GCDC [as 别名]
def _draw_ring_layer(self, dc, data, map_rel):
"""Draw a points layer.
dc the device context to draw on
data an iterable of point tuples:
(x, y, place, radius, colour, x_off, y_off, pdata)
map_rel points relative to map if True, MUST BE TRUE for lightweight
Assumes all points are the same colour, saving 100's of ms.
"""
assert map_rel is True
if len(data) == 0:
return
(lon, lat, place, radius, colour, x_off, y_off, pdata) = data[0]
scale = 2 ** self._pyslip.tiles.zoom_level
# Draw points on map/view, using transparency if implemented.
try:
dc = wx.GCDC(dc)
except NotImplementedError:
pass
dc.SetPen(wx.Pen(colour))
dc.SetBrush(wx.Brush(colour, wx.TRANSPARENT))
for (lon, lat, place, radius, colour, x_off, y_off, pdata) in data:
(x, y) = self._pyslip.ConvertGeo2View((lon, lat))
dc.DrawCircle(x, y, radius * scale)
示例6: LightweightDrawPointLayer
# 需要导入模块: import wx [as 别名]
# 或者: from wx import GCDC [as 别名]
def LightweightDrawPointLayer(self, dc, data, map_rel):
"""Draw a points layer.
dc the device context to draw on
data an iterable of point tuples:
(x, y, place, radius, colour, x_off, y_off, pdata)
map_rel points relative to map if True, MUST BE TRUE for lightweight
Assumes all points are the same colour, saving 100's of ms.
"""
assert map_rel is True
if len(data) == 0:
return
(lon, lat, place, radius, colour, x_off, y_off, pdata) = data[0]
# draw points on map/view
if map_rel:
# GCDC device context permits antialiasing and transparent colors.
# But, signficant time savings by not allowing these features
# It's not clear that we actually want or use them anyway
# dc = wx.GCDC(dc) # allow transparent colours
dc.SetPen(wx.Pen(colour))
dc.SetBrush(wx.Brush(colour))
for (lon, lat, place, radius, colour, x_off, y_off, pdata) in data:
pt = self.ConvertGeo2ViewMasked((lon, lat))
if pt:
(x, y) = pt
if radius:
dc.DrawCircle(x + x_off, y + y_off, radius)
示例7: DrawPointLayer
# 需要导入模块: import wx [as 别名]
# 或者: from wx import GCDC [as 别名]
def DrawPointLayer(self, dc, data, map_rel):
"""Draw a points layer.
dc the device context to draw on
data an iterable of point tuples:
(x, y, place, radius, colour, x_off, y_off, pdata)
map_rel points relative to map if True, else relative to view
"""
# draw points on map/view
if map_rel:
dc = wx.GCDC(dc) # allow transparent colours
for (lon, lat, place, radius, colour, x_off, y_off, pdata) in data:
pt = self.ConvertGeo2ViewMasked((lon, lat))
if pt:
dc.SetPen(wx.Pen(colour))
dc.SetBrush(wx.Brush(colour))
(x, y) = pt
if radius:
dc.DrawCircle(x + x_off, y + y_off, radius)
else:
(dc_w, dc_h) = dc.GetSize()
dc_w2 = dc_w / 2 # noqa; lgtm; self-modifying code
dc_h2 = dc_h / 2 # noqa; lgtm; self-modifying code
dc_h -= 1
dc_w -= 1
dc = wx.GCDC(dc) # allow transparent colours
for (x, y, place, radius, colour, x_off, y_off, pdata) in data:
dc.SetPen(wx.Pen(colour))
dc.SetBrush(wx.Brush(colour))
exec(self.point_view_placement[place])
if radius:
dc.DrawCircle(x, y, radius)
示例8: _draw_rings_layer
# 需要导入模块: import wx [as 别名]
# 或者: from wx import GCDC [as 别名]
def _draw_rings_layer(self, dc, data, map_rel):
"""Draw a points layer.
dc the device context to draw on
data an iterable of point tuples:
(x, y, place, radius, colour, x_off, y_off, pdata)
map_rel points relative to map if True, MUST BE TRUE for lightweight
Assumes all points are the same colour, saving 100's of ms.
"""
assert map_rel is True
if len(data) == 0:
return
(lon, lat, place, radius, colour, x_off, y_off, pdata) = data[0]
scale = 2 ** self._pyslip.tiles.zoom_level
# Draw points on map/view, using transparency if implemented.
try:
dc = wx.GCDC(dc)
except NotImplementedError:
pass
dc.SetPen(wx.Pen(colour))
dc.SetBrush(wx.Brush(colour, wx.TRANSPARENT))
for (lon, lat, place, radius, colour, x_off, y_off, pdata) in data:
(x, y) = self._pyslip.ConvertGeo2View((lon, lat))
dc.DrawCircle(x, y, radius * scale)
示例9: __on_paint
# 需要导入模块: import wx [as 别名]
# 或者: from wx import GCDC [as 别名]
def __on_paint(self, _event):
pdc = wx.BufferedPaintDC(self)
try:
dc = wx.GCDC(pdc)
except:
dc = pdc
w, h = self.GetClientSize()
font = self.GetFont()
font.SetPixelSize((0, h - (TICK_SIZE_MAJ * 2)))
dc.SetFont(font)
dc.SetPen(wx.Pen(wx.WHITE))
dc.SetBrush(wx.Brush(wx.WHITE))
dc.DrawRectangle(0, 0, w, h)
colour = '#4DDB4D' if self._value >= self._threshold else '#FF4D4D'
dc.SetPen(wx.Pen(colour))
dc.SetBrush(wx.Brush(colour))
x = self.__scale_x(self._value, w)
dc.DrawRectangle(0, 0, x, h)
colour = wx.Colour(0x80, 0x80, 0xFF, 128)
dc.SetPen(wx.Pen(colour, 2))
dc.SetBrush(wx.Brush(colour))
x = round(self.__scale_x(self._threshold, w))
dc.DrawPolygon([(x - THRES_SIZE, 0),
(x + THRES_SIZE, 0),
(x, THRES_SIZE)])
dc.DrawPolygon([(x - THRES_SIZE, h),
(x + THRES_SIZE, h),
(x, h - THRES_SIZE)])
dc.DrawLine(x, THRES_SIZE, x, h - THRES_SIZE)
if self._noise is not None:
dc.SetPen(wx.Pen('#8080FF', 1))
x = self.__scale_x(self._noise, w)
dc.DrawRectangle(0, TICK_SIZE_MAJ * 3 / 2.,
x, h - (TICK_SIZE_MAJ * 3))
colour = wx.Colour(0x4d, 0x4d, 0x4d)
dc.SetPen(wx.Pen(colour))
dc.SetTextForeground(colour)
ticks = range(LEVEL_MIN, LEVEL_MAX, 10)
for tick in ticks:
if tick not in [LEVEL_MIN, LEVEL_MAX]:
x = self.__scale_x(tick, w)
dc.DrawLine(x, 0, x, TICK_SIZE_MAJ)
dc.DrawLine(x, h, x, h - TICK_SIZE_MAJ)
label = str(tick)
tW, tH = dc.GetTextExtent(label)
dc.DrawText(label, x - tW / 2, (h - tH) / 2)
ticks = range(LEVEL_MIN, LEVEL_MAX, 1)
for tick in ticks:
if tick not in [LEVEL_MIN, LEVEL_MAX]:
x = self.__scale_x(tick, w)
dc.DrawLine(x, 0, x, TICK_SIZE_MIN)
dc.DrawLine(x, h, x, h - TICK_SIZE_MIN)
示例10: OnPaint
# 需要导入模块: import wx [as 别名]
# 或者: from wx import GCDC [as 别名]
def OnPaint(self, event):
dc = wx.BufferedPaintDC(self)
dc.Clear()
dc.BeginDrawing()
gc = wx.GCDC(dc)
width, height = self.GetClientSize()
gc.SetPen(wx.Pen(wx.NamedColour("GREY"), 3))
gc.SetBrush(wx.GREY_BRUSH)
gc.DrawLines(ArrowPoints(wx.TOP, width * 0.75, width * 0.5, 2, (width + height) // 4 - 3))
gc.DrawLines(ArrowPoints(wx.TOP, width * 0.75, width * 0.5, 2, (width + height) // 4 + 3))
gc.DrawLines(ArrowPoints(wx.BOTTOM, width * 0.75, width * 0.5, 2, (height * 3 - width) // 4 + 3))
gc.DrawLines(ArrowPoints(wx.BOTTOM, width * 0.75, width * 0.5, 2, (height * 3 - width) // 4 - 3))
thumb_rect = self.GetThumbRect()
exclusion_rect = wx.Rect(thumb_rect.x, thumb_rect.y,
thumb_rect.width, thumb_rect.height)
if self.Parent.IsMessagePanelTop():
exclusion_rect.y, exclusion_rect.height = width, exclusion_rect.y + exclusion_rect.height - width
if self.Parent.IsMessagePanelBottom():
exclusion_rect.height = height - width - exclusion_rect.y
if exclusion_rect != thumb_rect:
colour = wx.NamedColour("LIGHT GREY")
gc.SetPen(wx.Pen(colour))
gc.SetBrush(wx.Brush(colour))
gc.DrawRectangle(exclusion_rect.x, exclusion_rect.y,
exclusion_rect.width, exclusion_rect.height)
gc.SetPen(wx.GREY_PEN)
gc.SetBrush(wx.GREY_BRUSH)
gc.DrawPolygon(ArrowPoints(wx.TOP, width, width, 0, 0))
gc.DrawPolygon(ArrowPoints(wx.BOTTOM, width, width, 0, height))
gc.DrawRectangle(thumb_rect.x, thumb_rect.y,
thumb_rect.width, thumb_rect.height)
dc.EndDrawing()
event.Skip()
示例11: draw
# 需要导入模块: import wx [as 别名]
# 或者: from wx import GCDC [as 别名]
def draw(self, drawDC=None):
"""
Render the figure.
"""
# Render figure using agg
FigureCanvasAgg.draw(self)
# Get bitmap of figure rendered
self.bitmap = _convert_agg_to_wx_bitmap(self.get_renderer(), None)
if wx.VERSION < (3, 0, 0):
self.bitmap.UseAlpha()
# Create DC for rendering graphics in bitmap
destDC = wx.MemoryDC()
destDC.SelectObject(self.bitmap)
# Get Graphics Context for DC, for anti-aliased and transparent
# rendering
destGC = wx.GCDC(destDC)
destGC.BeginDrawing()
# Get canvas size and figure bounding box in canvas
width, height = self.GetSize()
bbox = self.GetAxesBoundingBox()
# If highlight to display is resize, draw thick grey line at bottom
# side of canvas
if self.Highlight == HIGHLIGHT_RESIZE:
destGC.SetPen(HIGHLIGHT['RESIZE_PEN'])
destGC.SetBrush(HIGHLIGHT['RESIZE_BRUSH'])
destGC.DrawRectangle(0, height - 5, width, 5)
# If highlight to display is merging graph, draw 50% transparent blue
# rectangle on left or right part of figure depending on highlight type
elif self.Highlight in [HIGHLIGHT_LEFT, HIGHLIGHT_RIGHT]:
destGC.SetPen(HIGHLIGHT['DROP_PEN'])
destGC.SetBrush(HIGHLIGHT['DROP_BRUSH'])
x_offset = (bbox.width // 2
if self.Highlight == HIGHLIGHT_RIGHT
else 0)
destGC.DrawRectangle(bbox.x + x_offset, bbox.y,
bbox.width // 2, bbox.height)
# Draw other Viewer common elements
self.DrawCommonElements(destGC, self.GetButtons())
destGC.EndDrawing()
self._isDrawn = True
self.gui_repaint(drawDC=drawDC)
示例12: DrawViewer
# 需要导入模块: import wx [as 别名]
# 或者: from wx import GCDC [as 别名]
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()
示例13: LightweightDrawPointLayer2
# 需要导入模块: import wx [as 别名]
# 或者: from wx import GCDC [as 别名]
def LightweightDrawPointLayer2(self, dc, data, map_rel):
"""Draw a points layer.
dc the device context to draw on
data an iterable of point tuples:
(x, y, place, radius, colour, x_off, y_off, pdata)
map_rel points relative to map if True, MUST BE TRUE for lightweight
Assumes all points are the same colour, saving 100's of ms.
In contrast to LightweightDrawPointLayer, this function draws
rectangles or points (rather than circles) for performance reasons.
"""
assert map_rel is True
if len(data) == 0:
return
(lon, lat, place, radius, colour, x_off, y_off, pdata) = data[0]
# draw points on map/view
if map_rel:
# GCDC device context permits antialiasing and transparent colors.
# But, signficant time savings by not allowing these features
# It's not clear that we actually want or use them anyway
# dc = wx.GCDC(dc) # allow transparent colours
dc.SetPen(wx.Pen(colour))
dc.SetBrush(wx.Brush(colour))
points = []
rectangles = []
if radius:
diameter = 2 * radius
for (lon, lat, place, radius, colour, x_off, y_off, pdata) in data:
pt = self.ConvertGeo2ViewMasked((lon, lat))
if pt:
(x, y) = pt
if radius:
rectangles.append(
(x + x_off - radius, y + y_off - radius, diameter, diameter)
)
else:
points.append((x + x_off, y + y_off))
if len(points):
dc.DrawPointList(points)
if len(rectangles):
dc.DrawRectangleList(rectangles)