Automatically save window position.
This commit is contained in:
parent
9d39fad480
commit
b4199aa2fb
|
@ -23,7 +23,7 @@ def make_window(loc):
|
||||||
sg.Sizegrip(background_color='#FFFF88')]]
|
sg.Sizegrip(background_color='#FFFF88')]]
|
||||||
window = sg.Window('Postit',layout,
|
window = sg.Window('Postit',layout,
|
||||||
no_titlebar=True, grab_anywhere=True, margins=(0, 0), background_color='#FFFF88', element_padding=(0, 0), location=loc,
|
no_titlebar=True, grab_anywhere=True, margins=(0, 0), background_color='#FFFF88', element_padding=(0, 0), location=loc,
|
||||||
right_click_menu=[[''], ['Edit Me', 'Change Font', 'Save Location', 'Alpha', [str(x) for x in range(1, 11)], 'Choose Title', 'Exit', ]], keep_on_top=True,
|
right_click_menu=[[''], ['Edit Me', 'Change Font', 'Alpha', [str(x) for x in range(1, 11)], 'Choose Title', 'Exit', ]], keep_on_top=True,
|
||||||
font='_ 20', right_click_menu_font=text_font, resizable=True, finalize=True, alpha_channel=alpha)
|
font='_ 20', right_click_menu_font=text_font, resizable=True, finalize=True, alpha_channel=alpha)
|
||||||
window.set_min_size(window.size)
|
window.set_min_size(window.size)
|
||||||
|
|
||||||
|
@ -38,7 +38,9 @@ def main():
|
||||||
while True: # Event Loop
|
while True: # Event Loop
|
||||||
event, values = window.read()
|
event, values = window.read()
|
||||||
print(event, values)
|
print(event, values)
|
||||||
if event == sg.WIN_CLOSED or event == 'Exit':
|
if event in (sg.WIN_CLOSED, 'Exit'):
|
||||||
|
if event == 'Exit':
|
||||||
|
sg.user_settings_set_entry('-location-', window.current_location())
|
||||||
break
|
break
|
||||||
if event == 'Edit Me':
|
if event == 'Edit Me':
|
||||||
sg.execute_editor(__file__)
|
sg.execute_editor(__file__)
|
||||||
|
@ -46,9 +48,9 @@ def main():
|
||||||
font = sg.popup_get_text('Main Information Font and Size (e.g. courier 70)', default_text=sg.user_settings_get_entry('-font-'), keep_on_top=True, location=window.current_location())
|
font = sg.popup_get_text('Main Information Font and Size (e.g. courier 70)', default_text=sg.user_settings_get_entry('-font-'), keep_on_top=True, location=window.current_location())
|
||||||
if font:
|
if font:
|
||||||
sg.user_settings_set_entry('-font-', font)
|
sg.user_settings_set_entry('-font-', font)
|
||||||
_, window = window.close(), make_window(loc)
|
loc = window.current_location()
|
||||||
elif event == 'Save Location':
|
window.close()
|
||||||
sg.user_settings_set_entry('-location-', window.current_location())
|
window = make_window(loc)
|
||||||
elif event in [str(x) for x in range(1,11)]:
|
elif event in [str(x) for x in range(1,11)]:
|
||||||
window.set_alpha(int(event)/10)
|
window.set_alpha(int(event)/10)
|
||||||
sg.user_settings_set_entry('-alpha-', int(event)/10)
|
sg.user_settings_set_entry('-alpha-', int(event)/10)
|
||||||
|
|
Loading…
Reference in New Issue