MCPcopy
hub / github.com/PySimpleGUI/PySimpleGUI / gui

Function gui

DemoPrograms/Demo_Desktop_Widget_Email_Notification.py:26–69  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

24
25
26def gui():
27 sg.theme('Topanga')
28 sg.set_options(border_width=0, margins=(0, 0), element_padding=(4, 0))
29 color = ('#282923', '#282923')
30 layout = [[sg.Text('Email New Mail Notification' + 48 * ' '),
31 sg.Button('', image_data=refresh,
32 button_color=color,
33 key='-refresh-',
34 tooltip='refreshes Email'),
35 sg.Button('', image_data=red_x,
36 button_color=color,
37 key='-quit-',
38 tooltip='Closes window')],
39 [sg.Text('', key='-status-', size=(25, 1))], ]
40
41 for i in range(MAX_EMAILS):
42 layout.append([sg.Text('', size=(20, 1), key='{}date'.format(i), font='Sans 8'),
43 sg.Text('', size=(45, 1), font='Sans 8', key='{}from'.format(i))])
44
45 window = sg.Window('',
46 layout,
47 no_titlebar=True,
48 grab_anywhere=True,
49 keep_on_top=True,
50 alpha_channel=0,
51 finalize=True)
52
53 # move the window to the upper right corner of the screen
54 w, h = window.get_screen_dimensions()
55 window.move(w - 410, 0)
56 window.set_alpha(.9)
57 window.refresh()
58
59 status_elem = window['-status-']
60
61 while True:
62 status_elem.update('Reading...')
63 window.refresh()
64 read_mail(window)
65 status_elem.update('')
66 # return every 30 seconds
67 event, values = window.read(timeout=30 * 1000)
68 if event == '-quit-':
69 break
70
71
72def read_mail(window):

Calls 7

get_screen_dimensionsMethod · 0.95
moveMethod · 0.95
set_alphaMethod · 0.95
refreshMethod · 0.95
readMethod · 0.95
read_mailFunction · 0.85
updateMethod · 0.45

Tested by

no test coverage detected