diff --git a/PySimpleGUIWx/Demo Programs/Wx_Scrape_GitHub_Issues_System_Tray.py b/PySimpleGUIWx/Demo Programs/Wx_Scrape_GitHub_Issues_System_Tray.py new file mode 100644 index 00000000..a90686ff --- /dev/null +++ b/PySimpleGUIWx/Demo Programs/Wx_Scrape_GitHub_Issues_System_Tray.py @@ -0,0 +1,169 @@ +#!/usr/bin/env python +from PySimpleGUIWx import SystemTray +from PySimpleGUIWx import EVENT_SYSTEM_TRAY_ICON_DOUBLE_CLICKED +from PySimpleGUIWx import EVENT_SYSTEM_TRAY_ICON_ACTIVATED +from PySimpleGUIWx import EVENT_SYSTEM_TRAY_ICON_RIGHT_CLICK +from PySimpleGUIWx import EVENT_SYSTEM_TRAY_MESSAGE_CLICKED +import PySimpleGUIWx as sgwx +import PySimpleGUI as sg + +import subprocess +import re +# Import requests (to download the page) +import requests +import datetime + +# Import BeautifulSoup (to parse what we download) +from bs4 import BeautifulSoup + +# CCNSTANTS - CHANGE THESE TO MATCH YOUR SYSTEM +CHROME = r"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" +DISCORD = r"C:\Users\mike\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Discord Inc\Discord.lnk" +VIEW_ISSUES_URL = r'https://github.com/MikeTheWatchGuy/PySimpleGUI/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc' +PULL_REQUEST_URL = r'https://github.com/MikeTheWatchGuy/PySimpleGUI/compare/master...Dev-latest' + +ICON_FILE = r'C:\Python\PycharmProjects\GooeyGUI\default_icon.ico' + +# search github for total open issues and Issue Number of first issue +def get_num_issues(): + url = "https://github.com/MikeTheWatchGuy/PySimpleGUI/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc" + # set the headers like we are a browser, + headers = { + 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'} + # download the page + requests.adapters.DEFAULT_RETRIES = 25 + try: + response = requests.get(url, headers=headers) + except: + return 0,0 + # parse the downloaded homepage and grab all text, + soup = BeautifulSoup(response.text, "lxml") + # look for phrase "XXX Open" + findopen = re.compile(r"\d+ Open") + # get number of open issues + number_open_string = findopen.search(str(soup)).group(0) + num_open_issues = number_open_string[0:number_open_string.index(' ')] + # find the first issue in the list by earing for "issue-id-XXXX" + find_first_issue = re.compile(r'issue-id-\d+') + first_issue_string = find_first_issue.search(str(soup)).group(0) + first_issue = first_issue_string[9:] + return num_open_issues, first_issue + + +def gui(): + sg.ChangeLookAndFeel('Topanga') + + sg.SetOptions(border_width=0) + + layout = [ + [sg.T('GitHub Issues Watcher' + 5 * ' ', click_submits=True, key='GitHub'), + sg.Button('', size=(25,25), + image_data=red_x, + key='_quit_',button_color=(sg.LOOK_AND_FEEL_TABLE['Topanga']['TEXT'],sg.LOOK_AND_FEEL_TABLE['Topanga']['BACKGROUND']), + tooltip='Closes window')], + [sg.T('', key='_status_', size=(12, 1))], + [sg.T('', key='_numissues_', size=(20, 1))], + ] + + window = sg.Window('Issue watcher', + no_titlebar=True, + grab_anywhere=True, + keep_on_top=True, + alpha_channel=.8, # dim the lights a little + location=(2360,310), # locate in upper right corner of screen + ).Layout(layout).Finalize() + + window.Refresh() + status_elem = window.FindElement('_status_') + issues_elem = window.FindElement('_numissues_') + + initial_issue_count, initial_first_issue = get_num_issues() + seconds = 0 + poll_frequncy = 1000 + + while True: + event, values = window.Read(timeout=poll_frequncy) + if event in ('_quit_', None): + break + if seconds % 60 == 0 or event.startswith('GitHub'): # Every 60 seconds read GitHub + status_elem.Update('Reading...') + window.Refresh() + issues, first_issue = get_num_issues() + if issues == 0 and first_issue == 0: + print('Read error', time.time()) + continue + issues_elem.Update('{} Issues. {} is first issue'.format(issues, initial_first_issue)) + window.Refresh() + # if something changed, then make a popup + if issues != initial_issue_count or first_issue != initial_first_issue: + sg.PopupNoWait('Issues changed on GitHub ', 'First issue # is {}'.format(first_issue), background_color='red', keep_on_top=True) + initial_issue_count = issues + initial_first_issue = first_issue + status_elem.Update('') + else: + status_elem.Update('.' if seconds%2 else '') # blink a '.' every 2 seconds so know still running + + seconds += poll_frequncy/1000 + window.Close() + + + +def system_tray(): + + menu_def = ['Root', + ['E&xit']] + tray = SystemTray(menu=menu_def, data_base64=logo, tooltip='GitHub Issue Watcher') + # tray = SystemTray(menu=menu_def, filename= ICON_FILE, tooltip='GitHub Issue Watcher') + + # tray.Hide() + initial_issue_count, initial_first_issue = get_num_issues() + issues = first_issue = 0 + # The Event Loop runs every 5000ms + poll_frequncy = 5000 + seconds = 0 + print('Starting', datetime.datetime.now()) + + while True: + menu_item = tray.Read(timeout=2000) + if menu_item == 'Exit': + break + if menu_item == 'Run GUI': + tray.Update(data_base64=red_x) + gui() + tray.Update(data_base64=logo) + elif menu_item == EVENT_SYSTEM_TRAY_ICON_ACTIVATED: + tray.ShowMessage('Issue', '{} Issues\n{} First Issue'.format(issues, first_issue), messageicon=sgwx.SYSTEM_TRAY_MESSAGE_ICON_INFORMATION, ) + + if seconds % 12 == 0: # Every 60 seconds read GitHub + issues, first_issue = get_num_issues() + if issues != 0: + menu_def = ['root', + ['{} Issues'.format(issues), '{} First Issue'.format(first_issue), '---','&View Issues Online', '&Pull Request','&Discord', '---','&Run GUI', '&Refresh', 'E&xit']] + tray.Update(menu_def, tooltip='{} First Issue'.format(first_issue)) + # if something changed, then make a popup + if issues != initial_issue_count or first_issue != initial_first_issue: + sg.Popup('Issues changed on GitHub ', 'First issue # is {}'.format(first_issue), background_color='red', keep_on_top=True) + initial_issue_count = issues + initial_first_issue = first_issue + else: + print('Update failed', datetime.datetime.now()) + if menu_item in('Refresh', EVENT_SYSTEM_TRAY_ICON_DOUBLE_CLICKED): + issues, first_issue = get_num_issues() + tray.ShowMessage('Issue', '{} Issues\n{} First Issue'.format(issues, first_issue), messageicon=sgwx.SYSTEM_TRAY_MESSAGE_ICON_INFORMATION, ) + sp = subprocess.Popen([CHROME, VIEW_ISSUES_URL], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + elif menu_item == EVENT_SYSTEM_TRAY_MESSAGE_CLICKED or menu_item.startswith('View Issues'): + sp = subprocess.Popen([CHROME, VIEW_ISSUES_URL], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + elif menu_item.startswith('Pull'): + sp = subprocess.Popen([CHROME, PULL_REQUEST_URL], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + elif menu_item.startswith('Discord'): + sp = subprocess.Popen([DISCORD, r''], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + + seconds += poll_frequncy/1000 + +red_x = b"R0lGODlhEAAQAPeQAIsAAI0AAI4AAI8AAJIAAJUAAJQCApkAAJoAAJ4AAJkJCaAAAKYAAKcAAKcCAKcDA6cGAKgAAKsAAKsCAKwAAK0AAK8AAK4CAK8DAqUJAKULAKwLALAAALEAALIAALMAALMDALQAALUAALYAALcEALoAALsAALsCALwAAL8AALkJAL4NAL8NAKoTAKwbAbEQALMVAL0QAL0RAKsREaodHbkQELMsALg2ALk3ALs+ALE2FbgpKbA1Nbc1Nb44N8AAAMIWAMsvAMUgDMcxAKVABb9NBbVJErFYEq1iMrtoMr5kP8BKAMFLAMxKANBBANFCANJFANFEB9JKAMFcANFZANZcANpfAMJUEMZVEc5hAM5pAMluBdRsANR8AM9YOrdERMpIQs1UVMR5WNt8X8VgYMdlZcxtYtx4YNF/btp9eraNf9qXXNCCZsyLeNSLd8SSecySf82kd9qqc9uBgdyBgd+EhN6JgtSIiNuJieGHhOGLg+GKhOKamty1ste4sNO+ueenp+inp+HHrebGrefKuOPTzejWzera1O7b1vLb2/bl4vTu7fbw7ffx7vnz8f///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AABTBAQDAwMDAwMDAwICAgIDwgCRaGhpampqbGxxAAAAeNkqAAAAMwICAgICAgEBAQEBAQjHANtnZmZmZ2doaGriAAAAeNkqAAAAADQBAQEBAQEBAQEBAcYAs2dmZmZmZmZmZrEAAAAAeNkqAAAAAPwxAQEBAQEBAQEJxQCzZ2ZmZmZmZmZq1wAAAAAAeNkqAAAAAAAAVQIBAQEBAQvJAAAAkmZmZmZmZnIAAAAAAAAAeNkqAAAAAAAAAF4HAQEBAs4AAAAAAJRlZmdqsgAAAAAAAAAAeNkqAAAAAAAAAAAAW1RYAAAAAAAAAADjldb+AAAAAAAAAAAAeNkqAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAeNkq/////wAAAAD/B+B/AAAAAP4DwB8AAAAA+AGADwAAAADwAQAHAAAAAPACAAMAAAAA4AQAAwAAAADACAABAAAAAIAIAAEAAAAAgAgCHAAAAACACAMcAAAAAIAIAIEAAAAAwAwAQQAAAADABgBjAAAAAPADAB8AAAAA8AGAHwAAAAD8AMAHAAAAAOYAYAMAAAAAwgAwAQAAAACBgBgAAAAAAJjACAAAAAAAnEAIAAAAAACYAAgBAAAAAIAACAEAAAAAwAAQAwAAAADgACADAAAAAPAAQAcAAAAA8ACADwAAAAD8AcA/AAAAAP4D4H8AAAAA/4/w/wAAAAD/////AAAAAA==' + + +system_tray() diff --git a/PySimpleGUIWx/Demo Programs/Wx_System_Tray_Launcher.py b/PySimpleGUIWx/Demo Programs/Wx_System_Tray_Launcher.py new file mode 100644 index 00000000..90c0ae03 --- /dev/null +++ b/PySimpleGUIWx/Demo Programs/Wx_System_Tray_Launcher.py @@ -0,0 +1,41 @@ +import PySimpleGUIQt as sg +import webbrowser +import subprocess + +# Destinations +VIEW_ISSUES_URL = r'https://github.com/MikeTheWatchGuy/PySimpleGUI/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc' +PULL_REQUEST_URL = r'https://github.com/MikeTheWatchGuy/PySimpleGUI/compare/master...Dev-latest' +DISCORD = r"C:\Users\mike\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Discord Inc\Discord.lnk" + +def system_tray(): + + menu_def = ['UNUSED', + ['Discord', 'Chrome', 'Open Issues', 'Pull Request', 'Exit']] + # tray = sg.SystemTray(menu=menu_def, filename='myicon.ico', tooltip='My System Tray Launcher') + tray = sg.SystemTray(menu=menu_def, data_base64=logo, tooltip='My System Tray Launcher') + + # The Event Loop runs every 5000ms + poll_frequncy = 5000 + + tray.ShowMessage('Starup', 'System tray launcher has started') + + while True: + menu_item = tray.Read(timeout=poll_frequncy) + + if menu_item == 'Exit': + break + if menu_item == sg.EVENT_SYSTEM_TRAY_ICON_ACTIVATED: + # TODO Insert code to get number of emails... this is a demo only... + tray.ShowMessage('You clicked me', 'You have 18 new emails') + elif menu_item.startswith('Chrome'): # The launches do work however + webbrowser.open_new('http://') + elif menu_item.startswith('Open'): + webbrowser.open_new_tab(VIEW_ISSUES_URL) + elif menu_item.startswith('Pull'): + webbrowser.open_new_tab(PULL_REQUEST_URL) + elif menu_item == 'Discord': + sp = subprocess.Popen([DISCORD, ''], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + +logo = b'AAABAAEAISAAAAEACACoCQAAFgAAACgAAAAhAAAAQAAAAAEACAAAAAAAgAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAmGkwAJlqMACaajEAm2syAJxsMgCdbTMAmWs0AJttNgCbbjYAnW00AJxuNwCdbjQAnm40AJ9vNQCfcDcAnnA4AJ9xOQCgcDUAoXE2AKJyNwCjczgAo3Q5AKR0OACmdToApnY6AKd2OgCidDwApHY9AKV2PgCodzsApng+AKh4OwCoeDwAqXk8AKp5PACqej0Aq3s+AKx7PgCtfD4Arnw/AKZ4QACre0IArH1CAK59QACufkEAr35AAKp9RwCsf0YAo3tJAKd8SACmfUwAp39OAKl+SQCwfkAArIFMAK6CTQCvhE0AsYBCALKAQgC0gkQAtYRHALaERQC4hkYAuIdIALqHSAC7iEgAu4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QAa21tbW5ub3BwswAAeNkqAABTBAQDAwMDAwMDAwICAgIDwgCRaGhpampqbGxxAAAAeNkqAAAAMwICAgICAgEBAQEBAQjHANtnZmZmZ2doaGriAAAAeNkqAAAAADQBAQEBAQEBAQEBAcYAs2dmZmZmZmZmZrEAAAAAeNkqAAAAAPwxAQEBAQEBAQEJxQCzZ2ZmZmZmZmZq1wAAAAAAeNkqAAAAAAAAVQIBAQEBAQvJAAAAkmZmZmZmZnIAAAAAAAAAeNkqAAAAAAAAAF4HAQEBAs4AAAAAAJRlZmdqsgAAAAAAAAAAeNkqAAAAAAAAAAAAW1RYAAAAAAAAAADjldb+AAAAAAAAAAAAeNkqAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAeNkq/////wAAAAD/B+B/AAAAAP4DwB8AAAAA+AGADwAAAADwAQAHAAAAAPACAAMAAAAA4AQAAwAAAADACAABAAAAAIAIAAEAAAAAgAgCHAAAAACACAMcAAAAAIAIAIEAAAAAwAwAQQAAAADABgBjAAAAAPADAB8AAAAA8AGAHwAAAAD8AMAHAAAAAOYAYAMAAAAAwgAwAQAAAACBgBgAAAAAAJjACAAAAAAAnEAIAAAAAACYAAgBAAAAAIAACAEAAAAAwAAQAwAAAADgACADAAAAAPAAQAcAAAAA8ACADwAAAAD8AcA/AAAAAP4D4H8AAAAA/4/w/wAAAAD/////AAAAAA==' + +system_tray() \ No newline at end of file diff --git a/PySimpleGUIWx/Demo Programs/Wx_System_Tray_Simple.py b/PySimpleGUIWx/Demo Programs/Wx_System_Tray_Simple.py new file mode 100644 index 00000000..380ff7dc --- /dev/null +++ b/PySimpleGUIWx/Demo Programs/Wx_System_Tray_Simple.py @@ -0,0 +1,27 @@ +import PySimpleGUIWx as sg + +""" + System Tray Icon + Your very own peronsal status monitor in your system tray + Super easy to use. + 1. Find an icon file or use this default + 2. Create your menu defintion + 3. Add if statements to take action based on your input + +""" + +logo = b'iVBORw0KGgoAAAANSUhEUgAAACEAAAAgCAMA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/vK2/vO8/vO/wtTjwtXlzdrl/vTA/vPQAAAAiNpY5gAAAQB0Uk5T////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AFP3ByUAAAAJcEhZcwAAFw8AABcPASe7rwsAAAAYdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjEuMWMqnEsAAAKUSURBVDhPhdB3WE1xHMdxt5JV0dANoUiyd8kqkey996xclUuTlEKidO3qVnTbhIyMW/bee5NskjJLmR/f3++cK/94vP76Ps/n/Zx7z6mE/6koJowcK154vvHOL/GsKCZXkUgkWlf4vWGWq5tsDz+JWIzSokAiqXGe7nWu3HxhEYof7fhOqp1GtptQuMruVhQdxZ05U5G47tYUHbQ4oah6Fg9Z4ubm7i57JhQjdHS0RSzUPoG17u6zZTKZh8c8XlytqW9YWUOH1LqFOZ6enl5ec+XybFb0rweM1tPTM6yuq6vLs0lYJJfLvb19fHwDWGF0jh5lYNAe4/QFemOwxtfXz8/fPyBgwVMqzAcCF4ybAZ2MRCexJGBhYGBQUHDw4u1UHDG1G2ZqB/Q1MTHmzAE+kpCwL1RghlTaBt/6SaXS2kx9YH1IaOjSZST8vfA9JtoDnSngGgL7wkg4WVkofA9mcF1Sx8zMzBK4v3wFiYiMVLxlEy9u21syFhYNmgN7IyJXEYViNZvEYoCVVWOmUVvgQVSUQqGIjolRFvOAFd8HWVs34VoA+6OjY2JjY5Vxm4BC1UuhGG5jY9OUaQXci1MqlfHx8YmqjyhOViW9ZsUN29akJRmPFwkJCZsTSXIpilJffXiTzorLXYgtcxRJKpUqKTklJQ0oSt9FP/EonxVdNY4jla1kK4q2ZB6mIr+AipvduzFUzMSOtLT09IyMzMxtJKug/F0u/6dTexAWDcXXLGEjapKjfsILOLKEuYiSnTQeYCt3UHhbwEHjGMrETfBJU5zq5dSTcXC8hLJccSWP2cgLXHPu7cQNAcpyxF1dyjehAKb0cSYUAOXCUw6V8OFPgevTXFymC+fPPLU677Nw/1X8A/AbfAKGulaqFlIAAAAASUVORK5CYII=' + +menu_def = ['UNUSED', ['My', 'Simple', '---', 'Menu', 'Exit']] + +tray = sg.SystemTray(menu=menu_def, data_base64=logo) + +tray.ShowMessage('Starting', 'Now Starting the application') + +while True: + event = tray.Read() + if event == 'Exit': + break + elif event == 'Menu': # add your checks here + pass + tray.ShowMessage('Event', '{}'.format(event)) \ No newline at end of file