Merge pull request #3020 from PySimpleGUI/Dev-latest

Changed the exit button to use clickable text for a cleaner look
This commit is contained in:
PySimpleGUI 2020-06-16 12:39:26 -04:00 committed by GitHub
commit 50cf19a502
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 5 deletions

View File

@ -46,12 +46,14 @@ def main():
text_color=sg.YELLOWS[0], justification='center', key='text')], text_color=sg.YELLOWS[0], justification='center', key='text')],
[sg.Text('', size=(30, 8), font=('Courier New', 12), [sg.Text('', size=(30, 8), font=('Courier New', 12),
text_color='white', justification='left', key='processes')], text_color='white', justification='left', key='processes')],
[sg.Exit(button_color=('white', 'firebrick4'), pad=((15, 0), 0), size=(9, 1)), [sg.Text('Update every '),
sg.Spin([x+1 for x in range(10)], 3, key='spin')] sg.Spin([x+1 for x in range(10)], 3, key='spin'), sg.T('seconds '),
sg.Text('', enable_events=True, key='Exit')
]
] ]
window = sg.Window('CPU Utilization', layout, window = sg.Window('CPU Utilization', layout,
no_titlebar=True, keep_on_top=True, alpha_channel=.8, grab_anywhere=True) no_titlebar=True, keep_on_top=True, use_default_focus=False, alpha_channel=.8, grab_anywhere=True)
# start cpu measurement thread # start cpu measurement thread
thread = Thread(target=CPU_thread, args=(None,)) thread = Thread(target=CPU_thread, args=(None,))
@ -61,12 +63,12 @@ def main():
# ---------------- main loop ---------------- # ---------------- main loop ----------------
while True: while True:
# --------- Read and update window -------- # --------- Read and update window --------
event, values = window.read(timeout=timeout_value, timeout_key='Timeout') event, values = window.read(timeout_value)
# --------- Do Button Operations -------- # --------- Do Button Operations --------
if event in (sg.WIN_CLOSED, 'Exit'): if event in (sg.WIN_CLOSED, 'Exit'):
break break
timeout_value = int(values['spin']) * 1000 timeout_value = int(values['spin']) * 1000 # for now on, use spinner for timeout
cpu_percent = g_cpu_percent cpu_percent = g_cpu_percent
display_string = '' display_string = ''