How to execute a button automaticly when a certain number of characters entered is reached?

Hi.
How to execute a button automaticly when a certain number of characters entered is reached, like in pin numbers?
with example please.

before the main loop where not only the pin should be :crazy_face:

import wx

class Pin(wx.Dialog):
    def __init__(self, parent):
        super().__init__(
            parent, style=wx.STAY_ON_TOP|wx.BORDER_NONE)
        self.SetTransparent(128)
        wx.StaticText(self, label='Please give a 4-digit pin')
        self.Centre()
        # self.Maximize()

class WxApp(wx.App):

    def __init__(self):
        super().__init__(filename=None)

    def OnPreInit(self):
        self.check_pin = False
        self.char_hook = wx.EVT_CHAR_HOOK._getEvtType()
        self.pin_code = [wx.WXK_NUMPAD1, wx.WXK_NUMPAD2,
                                wx.WXK_NUMPAD3, wx.WXK_NUMPAD4]

    def FilterEvent( self, evt):
        if self.check_pin:
            if len(self.pin) < 4:
                if evt.GetEventType() == self.char_hook:
                    self.pin.append(evt.GetKeyCode())
                return self.Event_Skip
            self.pin_ok = bool(self.pin == self.pin_code)
            self.check_pin = not self.pin_ok
            self.pin.clear()
            if self.dlg_pin.__nonzero__() and\
                        not self.dlg_pin.IsBeingDeleted():
                self.dlg_pin.Destroy()
        return self.Event_Skip

    def OnInit(self):
        self.check_pin = True
        while self.check_pin:
            self.pin = []
            self.dlg_pin = Pin(None)
            self.dlg_pin.ShowModal()
            wx.MessageBox(
                'You got it..' if self.pin_ok else 'missed it..', caption='Pin')
        if self.pin_ok:
            # self.MainLoop()
            return True
        return False

WxApp()