现在,我是这样设置背景颜色的,
dc.DrawRectangle(0,0,width,height)
你知道设置背景颜色的更好方法吗?
最佳答案
如果您已经在 wx.DC
上绘制以绘制窗口的其余内容,那么最好的方法是设置背景画笔,然后清除 DC。像这样:
def OnPaint(self, event):
dc= wx.PaintDC(self)
dc.SetBackground(wx.Brush(someColour))
dc.Clear()
# other drawing stuff...
如果您使用窗口的 SetBackgroundColour
方法设置颜色,那么您可以使用它来代替一些固定的颜色值,如下所示:
def OnPaint(self, event):
dc= wx.PaintDC(self)
dc.SetBackground(wx.Brush(self.GetBackgroundColour()))
dc.Clear()
# other drawing stuff...
关于python - 使用 wx.DC 设置背景颜色的更好方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11766759/