From 8d7c2523f491444781e33f7a8f4be3619e46624d Mon Sep 17 00:00:00 2001 From: Daniel Weschke Date: Sun, 4 Apr 2021 23:32:00 +0200 Subject: [PATCH] add possibility to use icons instead --- controldeck.py | 11 ++++++++--- example/controldeck.conf | 2 ++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/controldeck.py b/controldeck.py index 02ac273..8b2c40f 100644 --- a/controldeck.py +++ b/controldeck.py @@ -133,10 +133,12 @@ def application(): id = iname.group(1)[:-1] # remove dot try: button_dict[id] += [{'text': i[iname.end(0)+1:], - 'command': config.get(i, 'command', fallback=None)}] + 'command': config.get(i, 'command', fallback=None), + 'icon': config.get(i, 'icon', fallback=None)}] except KeyError: button_dict[id] = [{'text': i[iname.end(0)+1:], - 'command': config.get(i, 'command', fallback=None)}] + 'command': config.get(i, 'command', fallback=None), + 'icon': config.get(i, 'icon', fallback=None)}] for i in volume_dict: for j in volume_dict[i]: if 'div'+i not in vars(): @@ -146,7 +148,10 @@ def application(): for j in button_dict[i]: if 'div'+i not in vars(): vars()['div'+i] = Div(classes="flex flex-wrap", a=wp) - Button(text=j['text'], command=j['command'], a=eval('div'+i)) + if j['icon'] is not None: + Button(inner_html=f"
", command=j['command'], a=eval('div'+i)) + else: + Button(text=j['text'], command=j['command'], a=eval('div'+i)) if not wp.components: # config not found or empty, therefore insert an empty div to not get an error diff --git a/example/controldeck.conf b/example/controldeck.conf index f9d0bad..23e1486 100644 --- a/example/controldeck.conf +++ b/example/controldeck.conf @@ -12,9 +12,11 @@ # command = shell command # second command # ... +# icon = Font Awesome name # : N. optional group/row specification # : NAME name of the button # : command command(s) to run +# : icon use icon instead of NAME (Font Awesome) [gui] width = 800