Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

from Tnthieding/persist IMPORTANT #84

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,5 @@ $RECYCLE.BIN/

# Windows shortcuts
*.lnk

.idea
54 changes: 0 additions & 54 deletions README.md

This file was deleted.

16 changes: 16 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
##############################
Windows 10 Toast Notifications
##############################

Fork of https://github.com/jithurjacob/Windows-10-Toast-Notifications.

An easy-to-use Python library for displaying Windows 10 Toast Notifications with support for notifications that persist
in the notification center.

Update original package's interface to support persistent notifications by passing ``duration=None``.

************
Installation
************

``pip install win10toast-persist``
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
pypiwin32
setuptools
33 changes: 16 additions & 17 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from operator import attrgetter
from os import path

from pip.req import parse_requirements
from setuptools import setup


def read(fname):
return open(path.join(path.dirname(__file__), fname)).read()

Expand All @@ -13,31 +13,30 @@ def from_here(relative_path):
return path.join(path.dirname(__file__), relative_path)


requirements_txt = list(map(str, map(
attrgetter("req"),
parse_requirements(from_here("requirements.txt"), session="")
)))

setup(
name="win10toast",
version="0.9",
install_requires=requirements_txt,
packages=["win10toast"],
name="win10toast-persist",
version="0.10.1",
install_requires=[
"pypiwin32",
"setuptools"
],
packages=["win10toast_persist"],
license="BSD",
url="https://github.com/jithurjacob/Windows-10-Toast-Notifications",
download_url = 'https://github.com/jithurjacob/Windows-10-Toast-Notifications/tarball/0.9',
url="https://github.com/tnthieding/Windows-10-Toast-Notifications",
download_url='',
description=(
"An easy-to-use Python library for displaying "
"Windows 10 Toast Notifications"
"Windows 10 Toast Notifications with support for "
"persisting notifications."
),
include_package_data=True,
package_data={
'': ['*.txt'],
'win10toast': ['data/*.ico'],
'win10toast_persist': ['data/*.ico'],
},
long_description=read('README.md'),
author="Jithu R Jacob",
author_email="jithurjacob@gmail.com",
long_description=read('README.rst'),
author="Jithu R. Jacob and Tyler N. Thieding",
author_email="python@thieding.com",
classifiers=[
"Development Status :: 3 - Alpha",
"Topic :: Utilities",
Expand Down
2 changes: 1 addition & 1 deletion test/test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from win10toast import ToastNotifier
from win10toast_persist import ToastNotifier

if __name__ == "__main__":
# Example
Expand Down
22 changes: 0 additions & 22 deletions win10toast/__main__.py

This file was deleted.

20 changes: 11 additions & 9 deletions win10toast/__init__.py → win10toast_persist/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# standard library
import logging
import threading
import time
from os import path
from time import sleep
from pkg_resources import Requirement
Expand Down Expand Up @@ -66,14 +67,15 @@ def _show_toast(self, title, msg,
:title: notification title
:msg: notification message
:icon_path: path to the .ico file to custom notification
:duration: delay in seconds before notification self-destruction
:duration: delay in seconds before notification self-destruction, None for no-self-destruction

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good


"""
message_map = {WM_DESTROY: self.on_destroy, }

# Register the window class.
self.wc = WNDCLASS()
self.hinst = self.wc.hInstance = GetModuleHandle(None)
self.wc.lpszClassName = str("PythonTaskbar") # must be a string
self.wc.lpszClassName = str("PythonTaskbar" + str(time.time()).replace('.', '')) # must be a string
self.wc.lpfnWndProc = message_map # could also specify a wndproc.
try:
self.classAtom = RegisterClass(self.wc)
Expand All @@ -90,7 +92,7 @@ def _show_toast(self, title, msg,
if icon_path is not None:
icon_path = path.realpath(icon_path)
else:
icon_path = resource_filename(Requirement.parse("win10toast"), "win10toast/data/python.ico")
icon_path = resource_filename(Requirement.parse("win10toast_persist"), "win10toast_persist/data/python.ico")
icon_flags = LR_LOADFROMFILE | LR_DEFAULTSIZE
try:
hicon = LoadImage(self.hinst, icon_path,
Expand All @@ -108,11 +110,10 @@ def _show_toast(self, title, msg,
WM_USER + 20,
hicon, "Balloon Tooltip", msg, 200,
title))
# take a rest then destroy
sleep(duration)
DestroyWindow(self.hwnd)
UnregisterClass(self.wc.lpszClassName, None)
return None
if duration is not None:
sleep(duration)
DestroyWindow(self.hwnd)
UnregisterClass(self.wc.lpszClassName, None)

def show_toast(self, title="Notification", msg="Here comes the message",
icon_path=None, duration=5, threaded=False):
Expand All @@ -121,7 +122,8 @@ def show_toast(self, title="Notification", msg="Here comes the message",
:title: notification title
:msg: notification message
:icon_path: path to the .ico file to custom notification
:duration: delay in seconds before notification self-destruction
:duration: delay in seconds before notification self-destruction, None for no-self-destruction

"""
if not threaded:
self._show_toast(title, msg, icon_path, duration)
Expand Down
File renamed without changes.