From 56df7f18728591dc8987c03e79747655d6036715 Mon Sep 17 00:00:00 2001 From: PySimpleGUI Date: Fri, 1 Oct 2021 19:17:43 -0400 Subject: [PATCH] Added minimize feature, excel custom icon --- .../Demo_Desktop_Widget_Launcher_Bar.py | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/DemoPrograms/Demo_Desktop_Widget_Launcher_Bar.py b/DemoPrograms/Demo_Desktop_Widget_Launcher_Bar.py index d07c9412..f3c15abb 100644 --- a/DemoPrograms/Demo_Desktop_Widget_Launcher_Bar.py +++ b/DemoPrograms/Demo_Desktop_Widget_Launcher_Bar.py @@ -10,15 +10,21 @@ import PySimpleGUI as sg 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/HlhKraT38Gbe9dviM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Agyu8/I63f1H5J3l/PVeWn1AAAAAElFTkSuQmCC' # 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", + excel_icon: r"C:\Program Files\Microsoft Office\root\Office16\excel.EXE", 'Notepad++': r"C:\Program Files\NotePad++\notepad++.exe", sg.EMOJI_BASE64_HAPPY_IDEA: sg.main_sdk_help, 'All Elements' : r'C:\Python\PycharmProjects\PSG\DemoPrograms\Demo_All_Elements.py', 'Exit': None} +MINIMIZED_IMAGE = sg.EMOJI_BASE64_HAPPY_THUMBS_UP + DEFAULT_SCREEN_BACKGROUND_COLOR = 'black' DEFAULT_BUTTON_SIZE = (None, None) @@ -44,7 +50,8 @@ def settings(window:sg.Window): def make_window(): 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 = [] 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' @@ -54,17 +61,23 @@ def make_window(): button = sg.Button(item, key=item, metadata=launcher_buttons[item], tooltip=tip, border_width=0) 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() 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) keep_on_top = sg.user_settings_get_entry('-keep on top-', True) + + 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, 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) + sg.theme_background_color(old_bg) return window @@ -73,7 +86,7 @@ def main(): window = make_window() while True: - event, values = window.read() + event, values = window.read(timeout=1000) # Not needed but handy while debugging # print(event, values) if event in (sg.WIN_CLOSE_ATTEMPTED_EVENT, 'Exit', sg.WIN_CLOSED): if event != sg.WIN_CLOSED: @@ -98,6 +111,12 @@ def main(): settings(window) window.close() 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()