def draw_ruler(self, dc):
dc.SetPen(wx.Pen((255,255,255), width=2, style=wx.SOLID))
x1 = max(self.imgbox[0], self.box[0])+5
x2 = min(self.imgbox[2], self.box[2])+x1-10
pixs = (x2-x1+10)*self.ips.size[1]/10.0/self.imgbox[2]
h = min(self.imgbox[1]+self.imgbox[3],self.box[3])-5
dc.DrawLineList([(x1,h,x2,h)])
dc.DrawLineList([(i,h,i,h-8) for i in np.linspace(x1, x2, 3)])
dc.DrawLineList([(i,h,i,h-5) for i in np.linspace(x1, x2, 11)])
dc.SetTextForeground((255,255,255))
k, unit = self.ips.unit
text = 'Unit = %.1f %s'%(k*pixs, unit)
dw,dh = dc.GetTextExtent(text)
dc.DrawText(text, (x2-dw, h-10-dh))
评论列表
文章目录