mpf-mc icon indicating copy to clipboard operation
mpf-mc copied to clipboard

Look into supporting the Kivy Inspector

Open seanirby opened this issue 4 years ago • 3 comments

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

seanirby avatar Apr 20 '20 20:04 seanirby

Wow that is cool. We probably do something different. I guess this is worth exploring.

Jan

jabdoa2 avatar Apr 20 '20 21:04 jabdoa2

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

seanirby avatar Apr 21 '20 02:04 seanirby

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

jabdoa2 avatar Apr 21 '20 06:04 jabdoa2