diff --git a/README.md b/README.md index 636ad56..b84ea0f 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ The `global` section can be used to define general styling. this includes: `background`: hex color `foreground`: hex color -`highlight`: hex color (color on hover) +`highlight`: hex color, color on hover `padding_x`: integer `padding_y`: integer @@ -36,6 +36,7 @@ All components have the following properties: Buttons are defined in a section that starts with `button:`, and perform an action when clicked. They're also highlighted on hover. They have the following extra properties: `command`: the shell command to run on click +`condition`: an evaluated expression that returns "true" if the button should be enabled. #### Label diff --git a/sysmenu.py b/sysmenu.py index 872a952..37ce773 100755 --- a/sysmenu.py +++ b/sysmenu.py @@ -94,6 +94,10 @@ def make_button(name: str): ) if 'font' in spec: button.configure(font = font(spec['font'])) + if 'condition' in spec: + state = beval(spec['condition']); + if state.lower() != "true": + button['state'] = 'disabled' components.append(button) def make_label(name: str):