how many time will the fuction be called when an event happen?400 times or more?!

Try changing your on_exit function to:

def on_exit(self, v):
a.acon += 1
v.Skip()

Gre7g

···

On 5/5/08, VespertineR vinvangoo@gmail.com wrote:

import wx
class a(wx.App):
acon = 0

def __init__(self):
    super(a, self).__init__()

    b()
    self.frame = wx.Frame(None, -1)
    self.timer = wx.Timer(self.frame)
    self.frame.Bind(wx.EVT_TIMER, self.on_timer, self.timer)
    self.timer.Start(100)
    self.control = wx.TextCtrl(self.frame, -1, '', style=wx.TE_MULTILINE)

    self.frame.Show(True)
    self.MainLoop()
   
def on_timer(self, v):
    self.control.AppendText('a

.acon’ + str(a.acon) + ‘\n’)

class b(wx.Frame):
bcon = 0

def __init__(self):
    super(b, self).__init__(None, -1)
    self.Bind(wx.EVT_CLOSE, self.on_exit, self)

    self.Show(True)


def on_exit(self, v):
    a.acon += 1
    self.Show(False)
    self.Close()

a()

the output is:
acon 0
acon 0
acon 0

acon 0
acon 498 <-------------- I closed the window b
acon 498

when i close window b, the number of a.acon will suddenly trun to 400… wasn’t on_exit be called only once when I close the window b?..how can this happen?


wxpython-users mailing list
wxpython-users@lists.wxwidgets.org

http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

I’ve read this post with interest and I have a question now. VespertineR, why did you override the init method instead of the OnInit method of the wx.App?

And what is this super(b, self).init(None, -1) thing? Where is super() defined?

···

On Mon, May 5, 2008 at 5:40 PM, VespertineR vinvangoo@gmail.com wrote:

en it works~
thanks~.
self.Close() makes another wx.EVT_CLOSE event,and then self.on_exti() becomes a infinite loop -.- that’s the reason…

On Mon, May 5, 2008 at 11:36 PM, Gre7g Luterman gre7g.luterman@gmail.com wrote:

Try changing your on_exit function to:

def on_exit(self, v):
a.acon += 1

v.Skip()

Gre7g

On 5/5/08, VespertineR vinvangoo@gmail.com wrote:

import wx
class a(wx.App):
acon = 0

def __init__(self):
    super(a, self).__init__()

    b()
    self.frame = wx.Frame(None, -1)
    self.timer = wx.Timer(self.frame)
    self.frame.Bind(wx.EVT_TIMER, self.on_timer, self.timer)
    self.timer.Start(100)
    self.control = wx.TextCtrl(self.frame, -1, '', style=wx.TE_MULTILINE)



    self.frame.Show(True)
    self.MainLoop()
   
def on_timer(self, v):
    self.control.AppendText('a

.acon’ + str(a.acon) + ‘\n’)

class b(wx.Frame):
bcon = 0

def __init__(self):
    super(b, self).__init__(None, -1)
    self.Bind(wx.EVT_CLOSE, self.on_exit, self)



    self.Show(True)


def on_exit(self, v):
    a.acon += 1
    self.Show(False)
    self.Close()

a()

the output is:
acon 0
acon 0
acon 0

acon 0
acon 498 <-------------- I closed the window b
acon 498

when i close window b, the number of a.acon will suddenly trun to 400… wasn’t on_exit be called only once when I close the window b?..how can this happen?


wxpython-users mailing list
wxpython-users@lists.wxwidgets.org

http://lists.wxwidgets.org/mailman/listinfo/wxpython-users


wxpython-users mailing list

wxpython-users@lists.wxwidgets.org

http://lists.wxwidgets.org/mailman/listinfo/wxpython-users


wxpython-users mailing list

wxpython-users@lists.wxwidgets.org

http://lists.wxwidgets.org/mailman/listinfo/wxpython-users