From 1e5954cccac5646fa9741aa83c0d7edc30d1dd02 Mon Sep 17 00:00:00 2001 From: Valerie Date: Wed, 7 Jul 2021 15:09:13 -0400 Subject: [PATCH] added x padding and font options --- sysmenu.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sysmenu.py b/sysmenu.py index 7b5fcaf..d0486df 100755 --- a/sysmenu.py +++ b/sysmenu.py @@ -29,6 +29,7 @@ def get_config(section, key, globaldefault = True): background = get_config(menu, 'background') or 'white' foreground = get_config(menu, 'foreground') or 'black' highlight = get_config(menu, 'highlight') or 'gray' +padding_x = get_config(menu, 'padding_x') or 0 padding_y = get_config(menu, 'padding_y') or 0 root = Tk() @@ -48,6 +49,12 @@ def run(command): def beval(expression): return check_output(f'echo {expression}', shell = True).strip() +def font(name): + sec = f'font:{name}' + if sec not in config: + print(f'sysmenu: no font "{name}" (section "{sec}" missing)') + fontinfo = config[sec] + return (fontinfo['family'], fontinfo['size']) def make_button(name): spec = config[name] @@ -66,6 +73,7 @@ def make_button(name): fg = foreground, activeforeground = foreground, activebackground = highlight, + padx = padding_x, pady = padding_y ) components.append(button) @@ -84,8 +92,11 @@ def make_label(name): highlightthickness = 0, bg = background, fg = foreground, + padx = padding_x, pady = padding_y ) + if 'font' in spec: + label.configure(font = font(spec['font'])) components.append(label) items = config[menu]['items'].split()