Мне нужно как-то убрать задержку после первого нажатия на клавишу, но я не знаю как, помогите пожалуйста
import wx
import threading
import time
class GameWindow(wx.App):
class __DrawThread(threading.Thread):
def __init__(self, redraw_win):
threading.Thread.__init__(self)
self.stopped = False
self.redraw_win = redraw_win
self.start()
def run(self):
while self.stopped is not True:
self.repaint()
time.sleep(0.01)
def repaint(self):
dc = wx.ClientDC(self.redraw_win)
dc.Clear()
class __ComponentUpdateThread(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.stopped = False
self.start()
def run(self):
pass
class __EvtHandlerThread(threading.Thread):
def __init__(self, panel):
threading.Thread.__init__(self)
self.stopped = False
self.panel = panel
self.start()
def run(self):
self.panel.Bind(wx.EVT_KEY_DOWN, self.on_keyboard_down)
def on_keyboard_down(self, e):
print (e.GetKeyCode())
self.panel.Unbind(wx.EVT_KEY_DOWN)
self.panel.Bind(wx.EVT_KEY_DOWN, self.on_keyboard_down)
def __init__(self, title="Lucky Project", size=(600, 600)):
wx.App.__init__(self)
self.__frame__ = wx.Frame(parent=None, title=title, size=size)
self.__panel__ = wx.Panel(parent=self.__frame__)
self.__frame__.Bind(wx.EVT_CLOSE, self.__on_close)
self.__frame__.Center()
self.__frame__.Show()
self.__repaint_thread = self.__DrawThread(self.__panel__)
self.__component_update_thread = self.__ComponentUpdateThread()
self.__evt_handler_thread = self.__EvtHandlerThread(self.__panel__)
self.MainLoop()
def __on_close(self, e):
self.__frame__.Destroy()
self.__repaint_thread.stopped = True
self.__component_update_thread.stopped = True
self.__evt_handler_thread.stopped = True
win = GameWindow()