mpf-mc
mpf-mc copied to clipboard
Look into supporting the Kivy Inspector
Kivy has an inspector that may be worth including in mpf-mc. I followed their example here and was able to get it somewhat working but it looks like it only picks up children in the widget tree down to the DisplayOutput. I wonder if we're doing something in DisplayOutput that prevents it from recognizing the widgets it contains.
If you'd like to try it out you can update MpfMc.displays_initialized
to the following:
def displays_initialized(self, *args):
del args
self.validate_machine_config_section('window')
from mpfmc.uix.window import Window
Window.initialize(self)
### add these lines
from kivy.core.window import Window as KivyWindow
from kivy.modules import inspector
inspector.create_inspector(KivyWindow, self)
self.events.post('displays_initialized')
Once your game is running you can press Ctrl-E to toggle the inspector.
Example https://ibb.co/T4Shjjy
Wow that is cool. We probably do something different. I guess this is worth exploring.
Jan
So the issue is that Kivy's inspector is looking for a list of children on each widget in the widget tree. DisplayOutput explicity doesn't add children.
I put together a proof of concept here by updating the DisplayOutput class to manage its own children list. It works but I'm not sure if this is safe to do. If you want to try it out I've got the changes on this branch: https://github.com/seanirby/mpf-mc/tree/kivy-inspector
The reason for that is that a display can be attached to multiple display widgets. That is a concept which is missing in kivy. However, I don't think this would hurt. I will try that in my machine later as I use that feature