From c35dc6de7a8978afc94917082e488755f08e3059 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Wed, 17 Oct 2018 11:15:49 -0400 Subject: [PATCH] New Demo - demonstrate buttons in code and alpha channel --- Demo_Notification_Window_Alpha_Channel.py | 40 +++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Demo_Notification_Window_Alpha_Channel.py diff --git a/Demo_Notification_Window_Alpha_Channel.py b/Demo_Notification_Window_Alpha_Channel.py new file mode 100644 index 00000000..4975a3d6 --- /dev/null +++ b/Demo_Notification_Window_Alpha_Channel.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python +import sys +import time +if sys.version_info[0] >= 3: + import PySimpleGUI as sg +else: + import PySimpleGUI27 as sg + +# Demonstrates a notification window that's partially transparent +# The window slowly fades-in +# Includes a small red-X button to close the window +# Base 64 encoded button is in-lined to avoid reading a file +# Free online encoder - https://www.base64-image.de/ +red_x ="R0lGODlhEAAQAPeQAIsAAI0AAI4AAI8AAJIAAJUAAJQCApkAAJoAAJ4AAJkJCaAAAKYAAKcAAKcCAKcDA6cGAKgAAKsAAKsCAKwAAK0AAK8AAK4CAK8DAqUJAKULAKwLALAAALEAALIAALMAALMDALQAALUAALYAALcEALoAALsAALsCALwAAL8AALkJAL4NAL8NAKoTAKwbAbEQALMVAL0QAL0RAKsREaodHbkQELMsALg2ALk3ALs+ALE2FbgpKbA1Nbc1Nb44N8AAAMIWAMsvAMUgDMcxAKVABb9NBbVJErFYEq1iMrtoMr5kP8BKAMFLAMxKANBBANFCANJFANFEB9JKAMFcANFZANZcANpfAMJUEMZVEc5hAM5pAMluBdRsANR8AM9YOrdERMpIQs1UVMR5WNt8X8VgYMdlZcxtYtx4YNF/btp9eraNf9qXXNCCZsyLeNSLd8SSecySf82kd9qqc9uBgdyBgd+EhN6JgtSIiNuJieGHhOGLg+GKhOKamty1ste4sNO+ueenp+inp+HHrebGrefKuOPTzejWzera1O7b1vLb2/bl4vTu7fbw7ffx7vnz8f///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAJAALAAAAAAQABAAAAjUACEJHEiwYEEABniQKfNFgQCDkATQwAMokEU+PQgUFDAjjR09e/LUmUNnh8aBCcCgUeRmzBkzie6EeQBAoAAMXuA8ciRGCaJHfXzUMCAQgYooWN48anTokR8dQk4sELggBhQrU9Q8evSHiJQgLCIIfMDCSZUjhbYuQkLFCRAMAiOQGGLE0CNBcZYmaRIDLqQFGF60eTRoSxc5jwjhACFWIAgMLtgUocJFy5orL0IQRHAiQgsbRZYswbEhBIiCCH6EiJAhAwQMKU5DjHCi9gnZEHMTDAgAOw==" + + +sg.ChangeLookAndFeel('Topanga') +sg.SetOptions(border_width=0, margins=(0,0)) +bcolor=('black', '#282923') + +sg.SetOptions(border_width=0, margins=(0,0)) + +layout = [[sg.T('Notification'+' '*14), + sg.Button('', image_data=red_x, button_color=('#282923', '#282923'))], + [sg.T('')], + [sg.T('You have 6 new emails')],] + +window = sg.Window('', + no_titlebar=True, + grab_anywhere=True, + keep_on_top=True, + alpha_channel=0 + ).Layout(layout).Finalize() + +# Classy fade-in +for i in range(1, 75, 2): + window.AlphaChannel = float(i)/100 + time.sleep(.01) + +event, values = window.Read() \ No newline at end of file