import threading
from transitions.extensions import HierarchicalMachine as Machine
+# All drawing operations should happen in the main thread
+# https://github.com/kivy/kivy/wiki/Working-with-Python-threads-inside-a-Kivy-application
+from kivy.clock import mainthread
+
class KeyMachine(Widget):
STATES = [
'initial',
def is_loaded_inactive(self):
return self.is_loaded_no_config() or self.is_loaded_no_actions()
+ @mainthread
def on_enter_configuring(self):
self.destroy_actions()
self.key.unset_description()
self.key.repeat_protection_finished()
# Callbacks
+ @mainthread
def key_loaded_callback(self):
self.key.parent.key_loaded_callback()
super(Key, self).__init__(**kwargs)
# Kivy events
+ @mainthread
+ def update_state(self, value):
+ self.machine_state = value
+
def on_key_sym(self, key, key_sym):
if key_sym != "":
self.configure()