Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

How to retrieve the mode config ?

65 views
Skip to first unread message

Marc Rechté

unread,
Jan 29, 2025, 12:29:42 PMJan 29
to MPF Users
I am trying to tweak MPF-MC which does not honour the widget_styles directive from the mode config file.

To get the machine config, one can do self.mc.machine_config['widget_styles'], but how to do the same for the mode file where a widget is defined ?

See mpfmc/uix/widget.py:379

Thanks

Anthony van Winkle

unread,
Jan 29, 2025, 8:05:16 PMJan 29
to MPF Users
Interesting! You may be the first person to actually attempt widget styles in a mode rather than in the main machine config :)

You can access a mode at self.mc.modes['mode_name'] and it should/may have a config property. I haven't tested but looking at the code, it looks like MC goes ahead and loads up all the modes and all their configs. My only hesitation is that MC tends to use stripped-down versions of things because MPF is the one that cares about most stuff, but hopefully self.mc.modes['mode_name'].config['widget_styles'] will get you what you need!

Marc Rechté

unread,
Jan 30, 2025, 2:10:20 AMJan 30
to MPF Users
Ok, but how do I get the mode_name where the widget is defined ?

Marc Rechté

unread,
Jan 30, 2025, 5:23:02 AMJan 30
to MPF Users
I think I found the solution: instead of looking for the styles in `mc.machine_config['widget_styles']`, this should rather be done from `mc.widget_styles`

Shall I send a PR ?

Anthony van Winkle

unread,
Jan 30, 2025, 10:27:24 AMJan 30
to MPF Users
Excellent find, yes please submit a PR and thank you for the fix!

Marc Rechté

unread,
Jan 31, 2025, 3:16:59 AMJan 31
to MPF Users
I also noticed that the digit group separator is not configurable, although the code made provision for it. I have another PR that corrects this, but it also impacts MPF (config_spec.yaml). How do I proceed ?

Anthony van Winkle

unread,
Feb 5, 2025, 11:15:52 PMFeb 5
to MPF Users
Ah, this is a tedious part. You need to first make a PR into the MPF repository config_spec.yaml with the updated change, and then MC will be able to consume the config spec and see the new option.
Reply all
Reply to author
Forward
0 new messages