Merge pull request #786 from MikeTheWatchGuy/Dev-latest

Demo program on using the SystemTray
This commit is contained in:
MikeTheWatchGuy 2018-11-25 16:40:15 -05:00 committed by GitHub
commit 5361081892
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 16 deletions

View File

@ -11,14 +11,26 @@ layout = [
window = sg.Window('My window').Layout(layout) window = sg.Window('My window').Layout(layout)
import PySimpleGUIQt as sg
menu_def = ['File', ['Hide::key', '&Open::key', '&Save',['1', '2', ['a','b']], '&Properties', 'E&xit']]
menu_def = ['File', ['Hide', '&Open', '&Save',['1', '2', ['a','b']], '&Properties', 'E&xit']] tray = sg.SystemTray('My Tray', menu=menu_def, data_base64=logo, tooltip='My PySimpleGUIQt tray icon')
tray = sg.SystemTray('My Tray', menu=menu_def, data_base64=logo)
while True: while True:
event, values = window.Read(timeout=200) menu_item = tray.Read(timeout=0)
if menu_item == sg.EVENT_SYSTEM_TRAY_ICON_ACTIVATED:
# tray.ShowMessage('Activation', 'You activated the icon', data_base64=logo)
pass
elif menu_item == sg.EVENT_SYSTEM_TRAY_MESSAGE_CLICKED:
tray.ShowMessage('Message Click', 'You clicked the message', data_base64=logo)
elif menu_item == sg.EVENT_SYSTEM_TRAY_ICON_DOUBLE_CLICKED:
tray.ShowMessage('Double click', 'Double clicked')
elif menu_item == 'Exit':
break
elif menu_item != sg.TIMEOUT_KEY:
print('Tray menu item = {}'.format(menu_item))
event, values = window.Read()
if event == 'Message': if event == 'Message':
print('showing message') print('showing message')
tray.ShowMessage('Title', 'message goes here', data_base64=logo) tray.ShowMessage('Title', 'message goes here', data_base64=logo)
@ -28,14 +40,7 @@ while True:
tray.Hide() tray.Hide()
elif event == 'UnHide': elif event == 'UnHide':
tray.UnHide() tray.UnHide()
#
menu_item = tray.Read(timeout=0) # if menu_item == 'Open':
if menu_item is not None: print(menu_item) # tray.ShowMessage('Title', 'message goes here',filename= r'C:\Python\PycharmProjects\GooeyGUI\Qt\logo500.png')
print("EXITING PROGRAM")
if menu_item == 'Exit':
break
if menu_item == 'Hide':
tray.Hide()
if menu_item == 'Open':
tray.ShowMessage('Title', 'message goes here',filename= r'C:\Python\PycharmProjects\GooeyGUI\Qt\logo500.png')