Merge pull request from MikeTheWatchGuy/Dev-latest

Dev latest
This commit is contained in:
MikeTheWatchGuy 2018-11-30 11:09:52 -05:00 committed by GitHub
commit 34b25f2406
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 2 deletions
PySimpleGUIQt/Demo Programs

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
import PySimpleGUIQt as sg import PySimpleGUIQt as sg
import subprocess
import re import re
# Import requests (to download the page) # Import requests (to download the page)
import requests import requests
@ -8,6 +8,13 @@ import requests
# Import BeautifulSoup (to parse what we download) # Import BeautifulSoup (to parse what we download)
from bs4 import BeautifulSoup 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'
# search github for total open issues and Issue Number of first issue # search github for total open issues and Issue Number of first issue
def get_num_issues(): def get_num_issues():
url = "https://github.com/MikeTheWatchGuy/PySimpleGUI/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc" url = "https://github.com/MikeTheWatchGuy/PySimpleGUI/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc"
@ -92,6 +99,7 @@ def system_tray():
# tray.Hide() # tray.Hide()
initial_issue_count, initial_first_issue = get_num_issues() initial_issue_count, initial_first_issue = get_num_issues()
issues = first_issue = 0
# The Event Loop runs every 5000ms # The Event Loop runs every 5000ms
poll_frequncy = 5000 poll_frequncy = 5000
seconds = 0 seconds = 0
@ -103,10 +111,13 @@ def system_tray():
tray.Update(data_base64=red_x) tray.Update(data_base64=red_x)
gui() gui()
tray.Update(data_base64=logo) tray.Update(data_base64=logo)
elif menu_item == sg.EVENT_SYSTEM_TRAY_ICON_ACTIVATED:
tray.ShowMessage('Issue', '{} Issues\n{} First Issue'.format(issues, first_issue), messageicon=sg.SYSTEM_TRAY_MESSAGE_ICON_INFORMATION, )
if seconds % 12 == 0: # Every 60 seconds read GitHub if seconds % 12 == 0: # Every 60 seconds read GitHub
issues, first_issue = get_num_issues() issues, first_issue = get_num_issues()
menu_def = ['root', menu_def = ['root',
['{} Issues'.format(issues), '{} First Issue'.format(first_issue), '---', '&Run GUI', '&Refresh', 'E&xit']] ['{} 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)) tray.Update(menu_def, tooltip='{} First Issue'.format(first_issue))
# if something changed, then make a popup # if something changed, then make a popup
if issues != initial_issue_count or first_issue != initial_first_issue: if issues != initial_issue_count or first_issue != initial_first_issue:
@ -116,6 +127,12 @@ def system_tray():
if menu_item in('Refresh', sg.EVENT_SYSTEM_TRAY_ICON_DOUBLE_CLICKED): if menu_item in('Refresh', sg.EVENT_SYSTEM_TRAY_ICON_DOUBLE_CLICKED):
issues, first_issue = get_num_issues() issues, first_issue = get_num_issues()
tray.ShowMessage('Issue', '{} Issues\n{} First Issue'.format(issues, first_issue), messageicon=sg.SYSTEM_TRAY_MESSAGE_ICON_INFORMATION, ) tray.ShowMessage('Issue', '{} Issues\n{} First Issue'.format(issues, first_issue), messageicon=sg.SYSTEM_TRAY_MESSAGE_ICON_INFORMATION, )
elif menu_item == sg.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 seconds += poll_frequncy/1000