Changed how custom titlebar and menubar are generated
This commit is contained in:
parent
d7ecb9927b
commit
bf872d0882
|
@ -14,12 +14,19 @@ def make_window(theme=None):
|
||||||
|
|
||||||
NAME_SIZE = 23
|
NAME_SIZE = 23
|
||||||
|
|
||||||
|
|
||||||
def name(name):
|
def name(name):
|
||||||
dots = NAME_SIZE-len(name)-2
|
dots = NAME_SIZE-len(name)-2
|
||||||
return sg.Text(name + ' ' + '•'*dots, size=(NAME_SIZE,1), justification='r',pad=(0,0), font='Courier 10')
|
return sg.Text(name + ' ' + '•'*dots, size=(NAME_SIZE,1), justification='r',pad=(0,0), font='Courier 10')
|
||||||
|
|
||||||
sg.theme(theme)
|
sg.theme(theme)
|
||||||
|
|
||||||
|
# NOTE that we're using our own LOCAL Menu element
|
||||||
|
if use_custom_titlebar:
|
||||||
|
Menu = sg.MenubarCustom
|
||||||
|
else:
|
||||||
|
Menu = sg.Menu
|
||||||
|
|
||||||
treedata = sg.TreeData()
|
treedata = sg.TreeData()
|
||||||
|
|
||||||
treedata.Insert("", '_A_', 'Tree Item 1', [1234], )
|
treedata.Insert("", '_A_', 'Tree Item 1', [1234], )
|
||||||
|
@ -59,8 +66,9 @@ def make_window(theme=None):
|
||||||
[name('StatusBar'), sg.StatusBar('StatusBar')],
|
[name('StatusBar'), sg.StatusBar('StatusBar')],
|
||||||
[name('Sizegrip'), sg.Sizegrip()] ]
|
[name('Sizegrip'), sg.Sizegrip()] ]
|
||||||
|
|
||||||
layout = [[sg.MenubarCustom([['File', ['Exit']], ['Edit', ['Edit Me', ]]], k='-CUST MENUBAR-',p=0)] if use_custom_titlebar else [sg.Menu([['File', ['Exit']], ['Edit', ['Edit Me', ]]], k='-CUST MENUBAR-',p=0)],
|
# Note - LOCAL Menu element is used (see about for how that's defined)
|
||||||
[sg.Checkbox('Use Custom Titlebar & Menubar', use_custom_titlebar, enable_events=True, k='-USE CUSTOM TITLEBAR-')],
|
layout = [[Menu([['File', ['Exit']], ['Edit', ['Edit Me', ]]], k='-CUST MENUBAR-',p=0)],
|
||||||
|
[sg.Checkbox('Use Custom Titlebar & Menubar', sg.theme_use_custom_titlebar(), enable_events=True, k='-USE CUSTOM TITLEBAR-')],
|
||||||
[sg.T('PySimpleGUI Elements - Use Combo to Change Themes', font='_ 18', justification='c', expand_x=True)],
|
[sg.T('PySimpleGUI Elements - Use Combo to Change Themes', font='_ 18', justification='c', expand_x=True)],
|
||||||
[sg.Col(layout_l), sg.Col(layout_r)]]
|
[sg.Col(layout_l), sg.Col(layout_r)]]
|
||||||
|
|
||||||
|
@ -76,6 +84,7 @@ window = make_window()
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
event, values = window.read()
|
event, values = window.read()
|
||||||
|
sg.Print(event, values)
|
||||||
if event == sg.WIN_CLOSED or event == 'Exit':
|
if event == sg.WIN_CLOSED or event == 'Exit':
|
||||||
break
|
break
|
||||||
if event == 'Edit Me':
|
if event == 'Edit Me':
|
||||||
|
|
Loading…
Reference in New Issue