m0_52877081
m0_52877081
2021-02-26 16:34

wxpython程序中listbox重写后变透明了,但为什么又不能加载数据?

class TMListBox(wx.ListBox):
    def __init__(self,parent,id=-1,pos=wx.DefaultPosition,size=wx.DefaultSize,
                 choices=None,style=wx.TRANSPARENT_WINDOW,validator=wx.DefaultValidator, name='TMListBox'):
        wx.ListBox.__init__(self,parent,id,pos,size,choices,style,validator,name)
        self.Bind(wx.EVT_PAINT,self.on_paint)
        self.Bind(wx.EVT_ERASE_BACKGROUND,lambda e: None)
        self.Bind(wx.EVT_SIZE,self.on_size)
    def on_paint(self,e):
        bdc=wx.PaintDC(self)
        dc=wx.GCDC(bdc)
        font_face=self.GetFont()
        font_color=self.GetForegroundColour()
        dc.SetFont(font_face)
        dc.SetTextForeground(font_color)
    def on_size(self,e):
        self.Refresh()
        e.Skip()

请教哪位大神,上面代码错哪了

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答