PySimpleGUI / ptoaster

Display a toaster-style window on your screen that fades in / fades out. Built-in or custom icons. Uses PySimpleGUI as the GUI SDK.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ptoaster

A Python Based "Toaster Notifier"

Displays a toaster-style window anywhere on your screen with fade-in/fade-out

ptoaster

Uses multi-processing so that the window is completely independent from any other windows you may have open in your application.

Requirements

ptoaster uses PySimpleGUI to display the small windows. You will need to install PySimpleGUI if it is not installed for you when you pip installed ptoaster

One of these will install it for you.

pip install PySimpleGUI
pip3 install PySimpleGUI

Icons

ptoaster includes a number of icons in the code itself.

If no icon is supplied, then the "Success" icon is used.

toaster (2)

toaster (6)

toaster (7)

toaster (1)

toaster (3)

toaster (4)

toaster (5)

toaster

Using

ptoaster enables you to display a toaster notification window without the need for your program to stop execution while it's being displayed. In other words, the call is a non-blocking call that immediately returns back to your program and the window display will be performed in paralell with your application.

There are only 2 required parameters, the title and the message. ptoaster.notify(title, message)

The full call signature for notify is:

def notify(title, message, icon=icon_success, display_duration_in_ms=DEFAULT_DISPLAY_DURATION_IN_MILLISECONDS,
           fade_in_duration=DEFAULT_FADE_IN_DURATION, alpha=0.9, location=None):
    """
    Displays a "notification window", default location is the bottom right corner of your display.
    
    Notification window has - an icon, a title, and a message
    
    The window will slowly fade in and out if desired.  Clicking on the window will cause it to move
    through the end the current "phase". For example, if the window was fading in and it was clicked,
    then it would immediately stop fading in and instead be fully visible.  It's a way for the user
    to quickly dismiss the window.

    :param title: (str) Text to be shown at the top of the window in a larger font
    :param message: (str) Text message that makes up the majority of the window
    :param icon: Union[bytes, str] A base64 encoded PNG/GIF image or PNG/GIF filename that will be displayed in the window
    :param display_duration_in_ms: (int) Number of milliseconds to show the window
    :param fade_in_duration: (int) Number of milliseconds to fade window in and out
    :param alpha: (float) Alpha channel. 0 - invisible 1 - fully visible
    :param location: Tuple[int, int] Location on the screen to display the window
    :return: (Any) The Process ID returned from calling multiprocessing.Process
    """

Sample Program

import ptoaster

# IMPORTANT - you need to make sure you call notify from the main program
if __name__ == '__main__':
    ptoaster.notify('Your Title', 'Your message... this is the most simple call possible.')
    ptoaster.notify('Upper Left', 'This one will show up in the upper left corner of the screen', 
                     location=(0,0), fade_in_duration=0)

Limitations / Future Additions

At the moment, the size of the text and the width of the window are somewhat hard coded. The height of the window can vary however.

A next logical step in expanding the capabilities will be to allow for changing the fonts, the width of the window, wtc.

The decision was made to keep things simple for this initial release. Better to get seomthing basic that works well shipped than something fancy and not quiite operational that never ships.

Hungry for more?

If you want more examples like this one to help in creating your GUI, then be sure and check out the many programs found at http://Demos.PySimpleGUI.org.

logo500

About

Display a toaster-style window on your screen that fades in / fades out. Built-in or custom icons. Uses PySimpleGUI as the GUI SDK.

License:GNU Lesser General Public License v3.0


Languages

Language:Python 100.0%