added the condition property for buttons

This commit is contained in:
Valerie Wolfe 2021-08-25 01:33:20 -04:00
parent 9a0563d8ff
commit b3aa77b416
2 changed files with 6 additions and 1 deletions

View file

@ -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

View file

@ -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):