如何使默认的白色直流背景变为不可见(透明)?在
运行以下示例,它在按钮上显示白色背景。我想去掉DC的白色背景。(只显示红色X)import wx
class drawover(wx.Window):
def __init__(self, parent):
wx.Window.__init__(self, parent)
self.Bind(wx.EVT_PAINT, self.OnPaint)
self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnErase)
self.Bind(wx.EVT_SET_FOCUS, self.OnFocus)
def OnFocus(self, evt):
self.GetParent().SetFocus()
def OnErase(self, evt):
pass
def OnPaint(self, evt):
dc = wx.PaintDC(self)
dc.BeginDrawing()
dc.SetPen(wx.Pen("RED", 1))
dc.DrawLineList([(0,0,100,100), (100,0,0,100)])
dc.EndDrawing()
class frame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, size=(600,600))
s = wx.BoxSizer(wx.VERTICAL)
self.tc1 = wx.TextCtrl(self, style=wx.TE_MULTILINE)
s.Add(self.tc1, 1, wx.EXPAND)
self.tc2 = wx.Button(self)
s.Add(self.tc2, 1, wx.EXPAND)
self.d = drawover(self.tc2)
self.tc2.Bind(wx.EVT_SIZE, self.OnSize2)
self.SetSizer(s)
self.Layout()
def OnSize2(self, evt):
self.d.SetSize((101,101))
if __name__ == '__main__':
a = wx.App(0)
b = frame()
b.Show(1)
a.MainLoop()