added x padding and font options
This commit is contained in:
parent
774f2128b4
commit
1e5954ccca
1 changed files with 11 additions and 0 deletions
11
sysmenu.py
11
sysmenu.py
|
@ -29,6 +29,7 @@ def get_config(section, key, globaldefault = True):
|
||||||
background = get_config(menu, 'background') or 'white'
|
background = get_config(menu, 'background') or 'white'
|
||||||
foreground = get_config(menu, 'foreground') or 'black'
|
foreground = get_config(menu, 'foreground') or 'black'
|
||||||
highlight = get_config(menu, 'highlight') or 'gray'
|
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
|
padding_y = get_config(menu, 'padding_y') or 0
|
||||||
|
|
||||||
root = Tk()
|
root = Tk()
|
||||||
|
@ -48,6 +49,12 @@ def run(command):
|
||||||
|
|
||||||
def beval(expression):
|
def beval(expression):
|
||||||
return check_output(f'echo {expression}', shell = True).strip()
|
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):
|
def make_button(name):
|
||||||
spec = config[name]
|
spec = config[name]
|
||||||
|
@ -66,6 +73,7 @@ def make_button(name):
|
||||||
fg = foreground,
|
fg = foreground,
|
||||||
activeforeground = foreground,
|
activeforeground = foreground,
|
||||||
activebackground = highlight,
|
activebackground = highlight,
|
||||||
|
padx = padding_x,
|
||||||
pady = padding_y
|
pady = padding_y
|
||||||
)
|
)
|
||||||
components.append(button)
|
components.append(button)
|
||||||
|
@ -84,8 +92,11 @@ def make_label(name):
|
||||||
highlightthickness = 0,
|
highlightthickness = 0,
|
||||||
bg = background,
|
bg = background,
|
||||||
fg = foreground,
|
fg = foreground,
|
||||||
|
padx = padding_x,
|
||||||
pady = padding_y
|
pady = padding_y
|
||||||
)
|
)
|
||||||
|
if 'font' in spec:
|
||||||
|
label.configure(font = font(spec['font']))
|
||||||
components.append(label)
|
components.append(label)
|
||||||
|
|
||||||
items = config[menu]['items'].split()
|
items = config[menu]['items'].split()
|
||||||
|
|
Loading…
Reference in a new issue