Added minimize feature, excel custom icon
This commit is contained in:
parent
d176dca6f8
commit
56df7f1872
|
@ -10,15 +10,21 @@ import PySimpleGUI as sg
|
||||||
|
|
||||||
Copyright 2021 PySimpleGUI
|
Copyright 2021 PySimpleGUI
|
||||||
"""
|
"""
|
||||||
|
excel_icon = b'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAACXBIWXMAAAsSAAALEgHS3X78AAAFB0lEQVRIx51We0xTZxQ/X3t5lZY+QLwgLYgg4MSJOAQCOgED23SgMjedr2mY2UQhwblHNpK5xCxTM+Nkf+Dc2NTMZJCpEF3YsqU6y5ZsGpextSD0AcKlBeVR+rrt/fbHhcv1tlTGSdN8j3O/33mfgxiGAR4hhDDG7D/MTgghAGA5+efcCbdAAgA+jGDLYDzuspuGByZck7JwSZYmw/9dARgAEEHE9Hhp08iAftBooEx6ytg1ZB4YtblpDwCsVKe11ZzlC8sJxNmA3c4A0D7vg0fWbqtZP2gyUCYDZTIO97tozyw2mhGce4t9mv86QggxDNOobW69p+219U+4HQEt5k8xMsXGFWv9zzEGDBghFCImSjJyC1KzCISQrufeXYse/g+FikNTYjVBGMac9vorDb8cPU8Ej5ZZNZAqXiuo4Ftf4I/BMds3utYnODkIDYxa6680AEBRek5GfHLDz5fxtGvyU1aWPpUPABgwxnieAMP20fO3vgcAZaSclMd8+esVzhKEWMwCIEDz10ASGp5GJgEAGRUdERqWpU7HMAWwSBE7HUKAECL8U0ytIqVhEqOt30m7AWBLdkmiitR2/XnH/C/HlhKraT38Gbe9dviMf54DIIwxIchABKhxd31mQurbzacvdrQlL0g4ta3O46MvdLTx2fSUMf/4LkBQtbZyXVr2rnPvcRrsWPP8oeIdAAgBIIREgihiMNOobcYYb88pA4CdeRtDiZCLHW3D9lFBklseUpYRasw5QXu97Jr9PXKMY4wBMCAI7OTWv7R1pXsyE5ZmJy17afUGu8vRqG0R8JDy6N15LwJA7pIVMTLlW2V7AYDVYVViOj+TAwDQXu8Xt1o+qqj+eGuNUhJ17mbL0PiIgCcqQlq6PJ9NaVmYhA0bllSRcn49CRxFzX/8VFuyMyMu2eFxNd5s9mfooszFJ6sA4EjpnucyC0pOvc6Z+sC6yg82HeAKqmiWcg8+zCCExCJROBH2xMYgqIOPmSgAB8Ce/PKFUdF3zP9kaTLeWL/t6HefChiWkomf73wfAC+QKmXhkT/WNcKUE5AqMoorfQAQQAN5hLRq7ZZJt7P28gmnx7U1uyQxOk7AM+6cbO/UtXd29Nj67W5He6eO3bZ36rqGzFOKYAjsg32Fm6Oliku/Xe+x9l27p335mdKDRa8IlKDGhj+58RUAHCnbK5dIT/zQNOODZysLU1cBYBzQBwqJbH/BZi/j+1p3FQCabl/1MUzl6g1qFflYuSZC1CpSrSLlEZEhIkKtWshu1SpSESHjcwo1cNGe8rM1YpGoe8gCAH8/uP9Oy+lFytikmPi+hxTHlk4uvl7bwG11716YLQT8Adw91j5+4/729xv+X963WjadOQQAr+a9kL/k6epLx7mCsHlV0f7CLTMazK/hODwutgkWL8t10u67FgP3Ts7i5Xz5AofpXDpaedZ6AMjSpCklUfsKKrirNcmZ/Flmnv0gXhH7YfmbXKIdqzjoNx1NddB5AozYR5tuXw3e9OUS6VQURYSEiUUi39wGFpbcPrrH1j+TsXhqUoLp1kyIiGPlBxE7AdA+78CotXvIwk5wBsrUa+t3etxBAASTnWCg4wcOgTEOERMaVZxGFVeyLJe9o31e88iggTLqB416ytQ1ZH7wyOqi3YLJzn9uFIBhjINN0ZxEDGYmnJPGkQH9YK+BMjs8TrWSrC7ePhdjBgYPuAgyu8/I63f1H5J3l/PVeWn1AAAAAElFTkSuQmCC'
|
||||||
|
|
||||||
# This is your master table.... keys are what will be shown on the bar. The item is what you want to happen.
|
# This is your master table.... keys are what will be shown on the bar. The item is what you want to happen.
|
||||||
launcher_buttons = {'PSG Main': sg.main,
|
launcher_buttons = {
|
||||||
|
sg.SYMBOL_DOWN_ARROWHEAD : None,
|
||||||
|
'PSG Main': sg.main,
|
||||||
'Word': r"C:\Program Files\Microsoft Office\root\Office16\WINWORD.EXE",
|
'Word': r"C:\Program Files\Microsoft Office\root\Office16\WINWORD.EXE",
|
||||||
|
excel_icon: r"C:\Program Files\Microsoft Office\root\Office16\excel.EXE",
|
||||||
'Notepad++': r"C:\Program Files\NotePad++\notepad++.exe",
|
'Notepad++': r"C:\Program Files\NotePad++\notepad++.exe",
|
||||||
sg.EMOJI_BASE64_HAPPY_IDEA: sg.main_sdk_help,
|
sg.EMOJI_BASE64_HAPPY_IDEA: sg.main_sdk_help,
|
||||||
'All Elements' : r'C:\Python\PycharmProjects\PSG\DemoPrograms\Demo_All_Elements.py',
|
'All Elements' : r'C:\Python\PycharmProjects\PSG\DemoPrograms\Demo_All_Elements.py',
|
||||||
'Exit': None}
|
'Exit': None}
|
||||||
|
|
||||||
|
MINIMIZED_IMAGE = sg.EMOJI_BASE64_HAPPY_THUMBS_UP
|
||||||
|
|
||||||
DEFAULT_SCREEN_BACKGROUND_COLOR = 'black'
|
DEFAULT_SCREEN_BACKGROUND_COLOR = 'black'
|
||||||
DEFAULT_BUTTON_SIZE = (None, None)
|
DEFAULT_BUTTON_SIZE = (None, None)
|
||||||
|
|
||||||
|
@ -44,7 +50,8 @@ def settings(window:sg.Window):
|
||||||
def make_window():
|
def make_window():
|
||||||
|
|
||||||
screen_background_color = sg.user_settings_get_entry('-screen color-', DEFAULT_SCREEN_BACKGROUND_COLOR)
|
screen_background_color = sg.user_settings_get_entry('-screen color-', DEFAULT_SCREEN_BACKGROUND_COLOR)
|
||||||
|
old_bg = sg.theme_background_color()
|
||||||
|
sg.theme_background_color(screen_background_color)
|
||||||
button_row = []
|
button_row = []
|
||||||
for item in launcher_buttons.keys():
|
for item in launcher_buttons.keys():
|
||||||
tip = 'Grab anywhere to move the launcher\nClick an item to launch something\nRight Click to get to settings'
|
tip = 'Grab anywhere to move the launcher\nClick an item to launch something\nRight Click to get to settings'
|
||||||
|
@ -54,17 +61,23 @@ def make_window():
|
||||||
button = sg.Button(item, key=item, metadata=launcher_buttons[item], tooltip=tip, border_width=0)
|
button = sg.Button(item, key=item, metadata=launcher_buttons[item], tooltip=tip, border_width=0)
|
||||||
button_row.append(button)
|
button_row.append(button)
|
||||||
|
|
||||||
layout = [button_row]
|
col_buttons = sg.Column([button_row], p=0, k='-BUTTON COL-')
|
||||||
|
col_minimized = sg.Column([[sg.Button(image_data=MINIMIZED_IMAGE, k='-MINIMIZED IMAGE-', button_color=sg.theme_background_color(), border_width=0)]], visible=False, k='-MINIMIZED COL-')
|
||||||
|
|
||||||
|
layout = [[sg.pin(col_minimized), sg.pin(col_buttons)]]
|
||||||
|
|
||||||
screen_size = sg.Window.get_screen_size()
|
screen_size = sg.Window.get_screen_size()
|
||||||
location = screen_size[0] // 2, screen_size[1] - 200 # set a default location centered and near the bottom of the screen
|
location = screen_size[0] // 2, screen_size[1] - 200 # set a default location centered and near the bottom of the screen
|
||||||
location = sg.user_settings_get_entry('-window location-', location)
|
location = sg.user_settings_get_entry('-window location-', location)
|
||||||
keep_on_top = sg.user_settings_get_entry('-keep on top-', True)
|
keep_on_top = sg.user_settings_get_entry('-keep on top-', True)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
window = sg.Window('Window Title', layout, location=location,
|
window = sg.Window('Window Title', layout, location=location,
|
||||||
keep_on_top=keep_on_top, no_titlebar=True, grab_anywhere=True, background_color=screen_background_color,
|
keep_on_top=keep_on_top, no_titlebar=True, grab_anywhere=True, background_color=screen_background_color,
|
||||||
auto_size_buttons=False, default_button_element_size=DEFAULT_BUTTON_SIZE, right_click_menu=sg.MENU_RIGHT_CLICK_EDITME_VER_SETTINGS_EXIT,
|
auto_size_buttons=False, default_button_element_size=DEFAULT_BUTTON_SIZE, right_click_menu=sg.MENU_RIGHT_CLICK_EDITME_VER_SETTINGS_EXIT,
|
||||||
enable_close_attempted_event=True, use_default_focus=False)
|
enable_close_attempted_event=True, use_default_focus=False)
|
||||||
|
sg.theme_background_color(old_bg)
|
||||||
|
|
||||||
return window
|
return window
|
||||||
|
|
||||||
|
@ -73,7 +86,7 @@ def main():
|
||||||
window = make_window()
|
window = make_window()
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
event, values = window.read()
|
event, values = window.read(timeout=1000) # Not needed but handy while debugging
|
||||||
# print(event, values)
|
# print(event, values)
|
||||||
if event in (sg.WIN_CLOSE_ATTEMPTED_EVENT, 'Exit', sg.WIN_CLOSED):
|
if event in (sg.WIN_CLOSE_ATTEMPTED_EVENT, 'Exit', sg.WIN_CLOSED):
|
||||||
if event != sg.WIN_CLOSED:
|
if event != sg.WIN_CLOSED:
|
||||||
|
@ -98,6 +111,12 @@ def main():
|
||||||
settings(window)
|
settings(window)
|
||||||
window.close()
|
window.close()
|
||||||
window = make_window()
|
window = make_window()
|
||||||
|
elif event == sg.SYMBOL_DOWN_ARROWHEAD:
|
||||||
|
window['-BUTTON COL-'].update(visible=False)
|
||||||
|
window['-MINIMIZED COL-'].update(visible=True)
|
||||||
|
elif event == '-MINIMIZED IMAGE-':
|
||||||
|
window['-BUTTON COL-'].update(visible=True)
|
||||||
|
window['-MINIMIZED COL-'].update(visible=False)
|
||||||
window.close()
|
window.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue