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()