你试过使用GraphicsContext
吗?
这是一些示例代码。GCDC
使用包装器应该很容易放入现有代码中。您可能只需要以下行:dc = wx.GCDC(dc)
渲染会慢很多!您可以将此设置为可由用户启用/禁用的选项。
替代文字 http://www.michaelfogleman.com/static/images/gcdc.png
import wx
import random
class Panel(wx.Panel):
def __init__(self, parent):
super(Panel, self).__init__(parent, -1)
self.Bind(wx.EVT_PAINT, self.on_paint)
self.lines = [[random.randint(0, 500) for i in range(4)] for j in range(100)]
def on_paint(self, event):
dc = wx.PaintDC(self)
dc = wx.GCDC(dc)
dc.SetUserScale(0.3, 0.3)
for line in self.lines:
dc.DrawLine(*line)
class Frame(wx.Frame):
def __init__(self):
super(Frame, self).__init__(None, -1, 'Test')
Panel(self)
if __name__ == "__main__":
app = wx.PySimpleApp()
frame = Frame()
frame.Show()
app.MainLoop()