为什么wxPython OnPaint方法没有触发wx.lib.scrolledpanel.ScrolledPanel?

时间:2013-06-23 20:21:53

标签: events wxpython panel lifecycle

首先,调试器不会触及我的断点。 它是在我的自定义类的OnPaint方法中的第一条指令处设置的。

import wx.aui, wx.lib.agw.aui
from wx.lib import platebtn
import wx.lib.scrolledpanel as spanel
class GuiScrolledPanel(spanel.ScrolledPanel):
    def __init__(self, *args, **kwargs):
        spanel.ScrolledPanel.__init__(self, *args, **kwargs)
        self.SetSizer(GuiSchemaSizer())   
        self.SetupScrolling()         
        self.caption = "No active schema - Create a new schema or load one "

    def OnChildFocus(self, *args, **kwargs):
        self.Layout()
        self.AdjustScrollbars()
        return spanel.ScrolledPanel.OnChildFocus(self, *args, **kwargs)

    def updateCaption(self, caption):
        self.caption = caption

    def OnPaint(self, *args, **kwargs):
        some_result = spanel.ScrolledPanel.OnPaint(self, *args, **kwargs)
        print  'OnPaint in MyDrawingArea'
        dc = wx.PaintDC(self)

        dc.BeginDrawing()
        if self.BufferBmp != None:
            print  '...drawing'
            dc.DrawBitmap(self.BufferBmp, 0, 0, True)
            #should draw smth here, but what's the point when the method isn't even called, heh?
        else:
            print  '...nothing to draw'
        dc.EndDrawing()
        return some_result 

很多:)

1 个答案:

答案 0 :(得分:0)

似乎OnPaint方法mstst注册事件wx.EVT_BIND

    self.Bind(wx.EVT_PAINT, self.OnPaint)