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)
评论列表
文章目录