def DrawValue(self, dc, rect, property, text):
print 'DrawValue:', text
#dc.SetPen( wxPen(propertyGrid->GetCellTextColour(), 1, wxSOLID) )
#pen = dc.GetPen()
#print pen.GetColour(), pen.GetStyle(), wx.PENSTYLE_SOLID
#dc.SetPen(wx.Pen(wx.Colour(0, 0, 255, 255), 1, wx.SOLID))
cell_renderer = property.GetCellRenderer(1)
cell_renderer.DrawText(dc, rect, 0, text) # property.get_value())#rect.x+15, rect.y)
#dc.DrawText(property.get_value(), rect.x+15, rect.y)
# if not property.IsValueUnspecified():
# dc.DrawText(property.get_value(), rect.x+5, rect.y)
python类SOLID的实例源码
def create_background(self):
w,h = self.GetSize()
self.background_bitmap = wx.EmptyBitmap(w, h)
dc = wx.MemoryDC(self.background_bitmap)
gc = wx.GraphicsContext_Create(dc)
dc.SetBrush(wx.Brush("#FFFFFF"))
dc.Clear()
dc.DrawRectangle(0,0,w,h)
off = h // self.chnls // 2
gc.SetPen(wx.Pen('#000000', width=1, style=wx.SOLID))
gc.SetBrush(wx.Brush("#FFFFFF", style=wx.TRANSPARENT))
dc.SetTextForeground("#444444")
if sys.platform in "darwin":
font, ptsize = dc.GetFont(), dc.GetFont().GetPointSize()
font.SetPointSize(ptsize - 3)
dc.SetFont(font)
else:
font = dc.GetFont()
font.SetPointSize(8)
dc.SetFont(font)
tickstep = w // 10
if tickstep < 40:
timelabel = "%.1f"
elif tickstep < 80:
timelabel = "%.2f"
elif tickstep < 120:
timelabel = "%.3f"
else:
timelabel = "%.4f"
timestep = (self.end - self.begin) * 0.1
for i, samples in enumerate(self.img):
y = h // self.chnls * i
if len(samples):
gc.DrawLines(samples)
dc.SetPen(wx.Pen('#888888', width=1, style=wx.DOT))
dc.DrawLine(0, y+off, w, y+off)
# for j in range(10):
# dc.SetPen(wx.Pen('#888888', width=1, style=wx.DOT))
# dc.DrawLine(j*tickstep, 0, j*tickstep, h)
# dc.DrawText(timelabel % (self.begin+j*timestep), j*tickstep+2, h-y-12)
dc.SetPen(wx.Pen('#000000', width=1))
dc.DrawLine(0, h-y, w, h-y)
dc.SelectObject(wx.NullBitmap)
def __init__(
self, parent=None, id=-1, pos=wx.DefaultPosition,
size=wx.DefaultSize,
style=wx.TAB_TRAVERSAL|wx.NO_BORDER|wx.FULL_REPAINT_ON_RESIZE,
name='SquareMap', model = None,
adapter = None,
labels = True,
highlight = True,
padding = 2,
margin = 0,
square_style = False,
):
"""Initialise the SquareMap
adapter -- a DefaultAdapter or same-interface instance providing SquareMap data api
labels -- set to True (default) to draw textual labels within the boxes
highlight -- set to True (default) to highlight nodes on mouse-over
padding -- spacing within each square and its children (within the square's border)
margin -- spacing around each square (on all sides)
square_style -- use a more-recursive, less-linear, more "square" layout style which
works better on objects with large numbers of children, such as Meliae memory
dumps, works fine on profile views as well, but the layout is less obvious wrt
what node is "next" "previous" etc.
"""
super( SquareMap, self ).__init__(
parent, id, pos, size, style, name
)
self.model = model
self.padding = padding
self.square_style = square_style
self.margin = margin
self.labels = labels
self.highlight = highlight
self.selectedNode = None
self.highlightedNode = None
self._buffer = wx.Bitmap(20, 20) # Have a default buffer ready
self.Bind( wx.EVT_PAINT, self.OnPaint)
self.Bind( wx.EVT_SIZE, self.OnSize )
if highlight:
self.Bind( wx.EVT_MOTION, self.OnMouse )
self.Bind( wx.EVT_LEFT_UP, self.OnClickRelease )
self.Bind( wx.EVT_LEFT_DCLICK, self.OnDoubleClick )
self.Bind( wx.EVT_KEY_UP, self.OnKeyUp )
self.hot_map = []
self.adapter = adapter or DefaultAdapter()
self.DEFAULT_PEN = wx.Pen( wx.BLACK, 1, wx.SOLID )
self.SELECTED_PEN = wx.Pen( wx.WHITE, 2, wx.SOLID )
self.OnSize(None)
def draw(self, dc, f, **key):
dc.SetPen(wx.Pen((255,255,0), width=1, style=wx.SOLID))
dc.SetTextForeground((255,255,0))
font = wx.Font(8, wx.FONTFAMILY_DEFAULT,
wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False)
dc.SetFont(font)
data = self.data[0 if len(self.data)==1 else key['cur']]
for i in range(len(data)):
pos = f(*(data[i][0], data[i][1]))
dc.SetBrush(wx.Brush((255,255,255)))
dc.DrawCircle(pos[0], pos[1], 2)
dc.SetBrush(wx.Brush((0,0,0), wx.BRUSHSTYLE_TRANSPARENT))
dc.DrawCircle(pos[0], pos[1], data[i][2]*key['k'])
dc.DrawText('id={}, r={}'.format(i, data[i][2]), pos[0], pos[1])