GithubHelp home page GithubHelp logo

tinywintoast's Introduction

TinyWinToast

📧 Tiny library to show windows toast

Description

I want use notification in my console player, but I want more powerful toast then in win10toast, so I write this lib.

Installation

pip install tinyWinToast

Examples:

See source code to get more information

Simple start:

To create simple toast:

getToast("Title", "Message", 'icon.jpg', crop="circle", duration="short", appId="MyApp", isMute=True).show()

Or you can create toast object

0# Simple toast

toast = Toast()
toast.setTitle("TITLE", maxLines=2)
toast.setMessage("MESSAGE", maxLines=2)
toast.setIcon('image.png', crop=CROP_NONE)
toast.show()

Imgur

1# More text and circle crop

toast = Toast()
toast.setTitle("TITLE", maxLines=1)
toast.setMessage("MESSAGE", maxLines=1)
toast.addText("MORE TEXT", maxLines=1)
toast.setIcon('image.png', crop=CROP_CIRCLE)
toast.show()

Imgur

2# Add hero image

toast = Toast()
toast.setTitle("TITLE", maxLines=1)
toast.setMessage("MESSAGE", maxLines=1)
toast.addText("MORE TEXT", maxLines=1)
toast.setIcon('icon.jpg', crop=CROP_CIRCLE)
toast.setHeroImage("heroimage.jpg")
toast.show()

Imgur

3# Add image

toast = Toast()
toast.setTitle("TITLE", maxLines=1)
toast.setMessage("MESSAGE", maxLines=1)
toast.addText("MORE TEXT", maxLines=1)
toast.setIcon('icon.jpg', crop=CROP_CIRCLE)
toast.setImage("image.jpg")
toast.show()

Imgur

4# More images

toast = Toast()
toast.setTitle("TITLE", maxLines=1)
toast.setMessage("MESSAGE", maxLines=1)
toast.addText("MORE TEXT", maxLines=1)
toast.setIcon('image.jpg', crop=CROP_CIRCLE)
toast.addImage("image.jpg")
toast.addImage("image.jpg")
toast.addImage("image.jpg")
toast.addImage("image.jpg")
toast.show()

Imgur

5# Text attribute

toast = Toast()
toast.setTitle("TITLE", maxLines=1)
toast.setMessage("MESSAGE", maxLines=1)
toast.addText("from email", placement="attribution", maxLines=1)
toast.setIcon('icon.jpg', crop=CROP_CIRCLE)
toast.show()

Imgur

6# Toast time

toast = Toast()
toast.setTitle("TITLE", maxLines=1)
toast.setMessage("MESSAGE", maxLines=1)
toast.setTime("2019-07-13T18:49:37.00Z")
toast.setIcon('icon.jpg', crop=CROP_CIRCLE)
toast.show()

Imgur

7# Add group text

toast = Toast()
toast.setTitle("TITLE", maxLines=1)
toast.setMessage("MESSAGE", maxLines=1)
toast.addGroupText("Message", maxLines=1, style=TEXT_STYLE_BASE, align=TEXT_ALIGN_LEFT)
toast.addGroupText("Message", maxLines=1, style=TEXT_STYLE_CAPTION_SUBTLE, align=TEXT_ALIGN_LEFT)
toast.addGroupText("Message", maxLines=1, style=TEXT_STYLE_BASE, align=TEXT_ALIGN_RIGHT)
toast.setIcon('icon.jpg', crop=CROP_CIRCLE)
toast.show()

Imgur

8# Toast progress

toast = Toast()
toast.setTitle("TITLE", maxLines=1)
toast.setMessage("MESSAGE", maxLines=1)
toast.addProgress(Progress(title="Title", value="0.6", valueStringOverride="15/20", status="Save..."))
toast.setIcon('icon.jpg', crop=CROP_CIRCLE)
toast.show()

Imgur

Update toast data

toast = Toast()
toast.setTitle("TITLE", maxLines=1)
toast.setMessage("MESSAGE", maxLines=1)
toast.setTag("mytag")
toast.setGroup("mygroup")
toast.setProgress(Progress(title="Title", value="0.2", valueStringOverride="15/20", status="Save..."))
toast.setIcon('icon.jpg', crop=CROP_NONE)
toast.show()

time.sleep(6)

toast.setProgress(Progress(title="Title", value="0.9", valueStringOverride="19/20", status="Save..."))
d = {'progressValue': "0.9", 'progressValueString': "19/20"}
#toast.show() # if you wand update all toast
toast.update(200, d)

9# Buttons and inputs

toast = Toast()
toast.setTitle("TITLE", maxLines=1)
toast.setMessage("MESSAGE", maxLines=1)
toast.addInput(Input(inputId="111", intype=INPUT_TEXT, placeHolderContent="Input text..."))
toast.addInput(Input(inputId="112", intype=INPUT_SELECTION, selections = [("1","Yes"), ("2","No"), ("3","Maybe")], defaultInput="1"))
toast.addButton(Button(content="Play", activationType=ACTION_TYPE_BACKGROUND, arguments="dismiss", pendingUpdate=False))
toast.addButton(Button(content="Pause", activationType=ACTION_TYPE_BACKGROUND, arguments="http://www.google.com", pendingUpdate=False))
toast.setIcon('icon.jpg', crop=CROP_CIRCLE)
toast.show()

Imgur

Also, you can load toast from script, or xml

toast.showFromXml("APP_ID", "XML_STRING")
toast.startFromScript(path_to_script.ps1)
toast.updateFromScript(path_to_script.ps1)

Also you can creage Config() and set some params

config = Config()
config.APP_ID = "myApp"
config.DURATION = DURATION_LONG
...
toast = Toast(config)

or

config = Config()
config.APP_ID = "myApp"
config.DURATION = DURATION_LONG
...
toast = Toast()
toast.setConfig(config)

tinywintoast's People

Contributors

j-city avatar

Stargazers

 avatar Cooper Hatfield avatar Павленко Дмитрий avatar Matthew Hawkes_ONS avatar Tiankai Ma avatar 凌莞~(=^▽^=) avatar  avatar Ian Koech avatar Saif avatar Ishtiak Ahmed Evan avatar  avatar Vikrant avatar Viacheslav avatar Daniel Pine avatar Semen Sereda avatar  avatar  avatar Grün Christian-Rolf avatar  avatar Koen Vijverberg avatar Guo Jia avatar  avatar Jack Tang avatar Ric Jenkin avatar Bogdanov Dmitry avatar

Watchers

James Cloos avatar Louie avatar  avatar

tinywintoast's Issues

Duplicate buttons when toast spawned in a function

Hello, I recently discovered this package and it works like a charm! Not sure if this is still actively maintained, but I discovered a bug where multiple copies of the button are created when I tried to dynamically create a toast in a function multiple times, for example

    import time
    def foo():
        toast = Toast()
        toast.setTitle("TITLE", maxLines=2)
        toast.setMessage("MESSAGE", maxLines=2)
        toast.addButton(
            Button(content="Button", activationType=ACTION_TYPE_BACKGROUND,
                   arguments="", pendingUpdate=False))
        toast.show()
    for _ in range(3):
        foo()
        time.sleep(1)

This creates three toast no problem, but the second time it spawns with two buttons, and the third time three buttons.

image

Let me know if there is future plan of looking into this, thank you!

Is the Browser-Button working?

In the example there is a button with an url. In my naive mind i thought it would open a browser with the specified argument but it doesn't :(. Is there even a way to handle a button?

toast.addButton(Button(content="Pause", activationType=ACTION_TYPE_BACKGROUND, arguments="http://www.google.com", pendingUpdate=False))

Image files not showing

I tried this code but image files not showing:

logo = os.path.join(root, "./visuals/logo/logo.ico")
toast = Toast()
toast.setTitle("TITLE", maxLines=1)
toast.setMessage("MESSAGE", maxLines=1)
toast.addText("from email", placement="attribution", maxLines=1)
toast.setIcon(logo, crop="none")
toast.show()

icon,heroimage and image not show images

Included test.py does not work

Trying to run tinyWinToast/test/test.py results in:

Traceback (most recent call last):
  File "test.py", line 4, in <module>
    toast = Toast()
NameError: name 'Toast' is not defined

on Python 3.6.8 & 3.7.2

and:

Traceback (most recent call last):
  File "test.py", line 1, in <module>
    import tinyWinToast.tinyWinToast
  File "C:\Python27\lib\site-packages\tinyWinToast\tinyWinToast.py", line 677, in <module>
    toast.show()
  File "C:\Python27\lib\site-packages\tinyWinToast\tinyWinToast.py", line 560, in show
    subprocess.run(["PowerShell", "-ExecutionPolicy", "Bypass", "-File", path + "toast.ps1"])
AttributeError: 'module' object has no attribute 'run'

on Python 2.7.15

Version installed is tinyWinToast-1.1
Windows 10, version 1809

Typo (?) in readme.md file

Hello. Thank you for sharing this useful package!

Minor comment for those coming across this package in the future: the crop argument takes "circle" and "none". It does not accept CROP_CIRCLE or CROP_NONE as stated in the readme.md file.

Edit:
My mistake, I just needed to use from tinyWinToast.tinyWinToast import * to get the CROP_CIRCLE and CROP_NONE objects, which equal "circle" and "none", respectively.

# !pip3 install tinyWinToast

from tinyWinToast.tinyWinToast import *

icon_path = "C:/Users/Matthew/Downloads/The-20-20-20-Rule.ico"

toast = Toast()
toast.setTitle("TITLE", maxLines=1)
toast.setMessage("MESSAGE", maxLines=1)
toast.addText("MORE TEXT", maxLines=1)

# Either of these works fine
toast.setIcon(icon_path, crop="circle")
toast.setIcon(icon_path, crop=CROP_CIRCLE)


toast.setHeroImage(icon_path)
toast.show()

Toast is not showing, and no errors are present

I have notifications enabled in the system settings, running following code yields no result (no toast notification or any error in console):

from tinyWinToast.tinyWinToast import Toast

toast = Toast()
toast.setTitle("test")
toast.setMessage("test message")
toast.show()

Python 3.6.8 / 3.7.2
tinyWinToast==1.1
Windows 10, version 1809

Toast display speed?

Is there a way to make the toast appear faster? Or is this strictly controlled by Windows?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.