【发布时间】:2010-01-31 23:17:47
【问题描述】:
我的 DC 有问题。我正在尝试制作一个将在屏幕上绘制许多线条并且需要非常快速地更新的应用程序,并且由于我不想闪烁,所以我决定试一试缓冲 dcs。但是当我运行这段代码时,它什么也没画。我做错了什么?
import wx
class MainFrame(wx.Frame):
def __init__(self):
screensize = wx.GetDisplaySize()
self.framesize = (screensize[0]/4*3, screensize[1]/4*3)
wx.Frame.__init__(self, None, -1, "CursorTracker", size=self.framesize,
style=wx.SYSTEM_MENU|
wx.CAPTION|
wx.CLOSE_BOX|
wx.MINIMIZE_BOX)
self.dc = wx.ClientDC(self)
self.bdc = wx.BufferedDC(self.dc)
self.SetBackgroundColour(wx.WHITE)
self.Timer = wx.Timer(self)
self.Bind(wx.EVT_TIMER, self.OnTimer)
self.Timer.Start(100)
def OnTimer(self, event):
self.bdc.DrawLine(1,1,100,100)
class App(wx.App):
def OnInit(self):
frame = MainFrame()
frame.Show()
return True
app = App(redirect=False)
app.MainLoop()
【问题讨论】: