def notify_popout(title=None, message=None, icon=sg.DEFAULT_BASE64_ICON, app_name=None): """ Show a notification popout window :param title: Title shown in the notification :param message: Message shown in the notification :param icon: Icon shown in the notification - defaults to PySimpleGUI icon. Should be a PNG file :param app_name: Application name shown in the notification """ if not hasattr(notify_popout, 'temp_files'): notify_popout.temp_files = [] notification = Notify() notification.title = title notification.message = message tmp = None if isinstance(icon, bytes): with tempfile.TemporaryFile(suffix='.png', delete=False) as tmp: tmp.write(base64.b64decode(icon)) tmp.close() notification.icon = tmp.name elif icon is not None: notification.icon = icon if app_name is not None: notification.application_name = app_name notification.send(block=False) if tmp is not None: notify_popout.temp_files.append(tmp.name)
def standard_message(lecture, time_left, logo): notification = Notify() notification.title = lecture notification.message = f'ლექციამდე დარჩენილია {time_left} საათი, არ დაგავიწყდეს BTU-სა და Google ქლასრუმებზე დავალების ნახვა.' notification.icon = logo notification.send()
def notify(self, title, description, duration=5): notification = Notify() notification.title = title notification.message = description notification.icon = "./assets/image/icon.png" notification.audio = "./assets/audio/notification.wav" notification.send()
def Notificacion(opciones): """ Muestra una notificacion de Escritorio texto -> str Texto de la notificacion titulo -> str Titulo de la notificacion icono -> str direcion del icono icono_relativo -> bool direcion del icono dentro de folder config """ if "texto" in opciones: Texto = opciones["texto"] Noti = Notify() Noti.message = Texto Noti.application_name = "ElGatoALSW" if "titulo" in opciones: Noti.title = opciones["titulo"] else: Noti.title = "ElGatoALSW" # TODO: Iconos relativo if "icono" in opciones: DirecionIcono = opciones["icono"] if "icono_relativo" in opciones: if opciones["icono_relativo"]: DirecionIcono = UnirPath(ObtenerFolderConfig, DirecionIcono) Noti.icon = DirecionIcono Noti.send()
def errorNotify(title, body): if thePlatform == "Linux" or thePlatform == "Darwin": from notifypy import Notify notif = Notify() notif.title = title notif.message = body notif.icon = "./icons/png/robloxnotif.png" notif.audio = path.realpath("./sounds/error.wav") notif.application_name = "robloxnotif" notif.send(block=True) elif thePlatform == "Windows": import win10toast from playsound import playsound toast = win10toast.ToastNotifier() toast.show_toast( title, body, duration=5, icon_path="./icons/robloxnotif.ico", threaded=True, sound=False, ) try: playsound(path.realpath("./sounds/error.wav")) except UnicodeDecodeError: pass while toast.notification_active(): sleep(0.1)
def _notify(title: str, body: str, image: str = None) -> None: notification = Notify() notification.title = title notification.message = body notification.icon = image if image and os.path.exists(image) else app_icon notification.application_name = APP_NAME notification.send(block=False)
def notification_send(title, message, config_dict, b_sound): notification = Notify() notification.title = title notification.message = message notification.icon = config_dict['PATH_NOTIF_ICON'] if b_sound: notification.audio = config_dict['PATH_NOTIF_SOUND'] notification.send()
def Birthday_Today_Notification(First, Last, Age): notification = Notify() notification.title = f"{First} {Last}'s Birthday!!!" notification.message = f"{First} is turning {Age} today! Make sure to wish them a happy birthday!" notification.icon = "Images\BirthdayCakeIcon.png" notification.application_name = "Birthday Tracker" notification.audio = r"Images\NotificationSound.wav" notification.send()
def opm_notify_main(): """Main function for Sending Notification Message to the Host Desktop The function is used in OPMRUN background scripts to send a status notification message to the host desktop, based on the augments supplied to the function, there are no parameters for this function. The function is used on a standalone basis and thus does not use the OPMRUN system variable directory. Augments -------- --title= : str The title to be used in the notification. If default with '' then 'OPMRUN Background Processing", will be used. --message= : dict The message to be displayed in the notification, should normally the job number and job name. --status= : int Status code used to display the icon in the notification set to one of the following: '' : for the default icon opmrun.png "0" : for pass and the opm_notify_pass.png icon "0" : for fail and the opm_notify_fail.png icon. Parameters ---------- None Returns ------- Issues notification message to the desktop. """ # # Read Arguments # title = '' message = '' pathdir = os.path.dirname(os.path.abspath(__file__)) icon = Path(pathdir) / 'opmrun.png' iconpass = Path(pathdir) / 'opmrun-pass.png' iconfail = Path(pathdir) / 'opmrun-fail.png' for cmd in sys.argv: if '--title=' in cmd: title = cmd.replace('--title=', '') if title is None: title = 'OPMRUN Background Processing' elif '--message=' in cmd: message = cmd.replace('--message=', '') elif '--status=' in cmd: status = cmd.replace('--status=', '') if status == '0': icon = iconpass elif status == '1': icon = iconfail notification = Notify() notification.application_name = 'OPMRUN Background Processing', notification.title = str(title) notification.message = str(message) notification.icon = icon notification.send(block=False)
def send_notification(self, title, message): if self.config.ENABLE_NOTIFICATIONS and sys.platform == 'win32': from notifypy import Notify notification = Notify() notification.title = title notification.message = message notification.application_name = "AzurLaneAutoScript" notification.icon = "assets/gooey/icon.ico" notification.send(block=False)
def notification_send(title="Empty", message="No message", icon=""): notify = Notify() notify.title = title notify.message = message try: notify.icon = icon notify.send(block=False) except (exceptions.InvalidIconPath): pass
def notify(title="Event", message=None, location=None): """Send a system notification""" notification = Notify() notification.title = title notification.message = message if location: message += f"\nLocation: {location}" notification.icon = "./schedule.png" notification.audio = "./Polite.wav" notification.send()
def notify(title, text): """ this function will only work on OSX and needs to be extended for other OS @title string for notification title @text string for notification content """ notification = Notify() notification.title = title notification.message = text notification.icon = os.path.join(os.path.dirname(__file__), '..', 'assets', 'icon.png') notification.send()
def prompt_for_touch(): try: click.echo('Touch your YubiKey...', err=True) notification = Notify() notification.title = "Touch your yubikey" notification.message = "Touch your yubikey" notification.audio = os.path.join(os.path.dirname(__file__), "notification_sound.wav") notification.icon = os.path.join(os.path.dirname(__file__), "yubikey.png") notification.send() except Exception: sys.stderr.write("Touch your YubiKey...\n")
def sendnofy(): #print(os.path.split(os.path.realpath(sys.argv[0]))) #print(os.getcwd()) # 运行路径在调用函数的 buffer 文件目录下 with open( 'E:\\spacemacs\\emacs26-3\\.emacs.d\\site-lisp\\notify\\Record.txt', 'r', encoding='utf-8') as f: notification = Notify() notification.title = f.readline() notification.message = f.readline() notification.icon = "E:\\spacemacs\\emacs26-3\\.emacs.d\\site-lisp\\notify\\logo.png" # notification.audio = "" notification.send()
def this_will_run_when_alarm_rings(alarm): if alarm[2] == 0: pass else: alarm_ = Alarms() time = alarm_.convert_to_12_hour_clock(minutes_from_minight=alarm[4]) notification = Notify() notification.title = alarm[1] notification.message = f"The time is {time[0]}:{time[1]} {time[2]}" notification.icon = "./Assets/Robert Logo.png" notification.audio = "./Assets/beep.wav" notification.send() alarm_.delete_alarm(alarm[0])
def notifier(): global timer_started, timer_running, clock_values timer_started = False timer_running = -1 clock_values = ['00','00','00'] n = Notify() n.title = "Timer" n.message = "Timer is over" n.audio = 'notification.wav' n.icon = 'timer.png' n.send()
def error(message: str) -> None: """ Sends an error notification as well as log into the log file. """ logging.error(message) if enable_notifications is False: return notification = Notify() notification.title = "LevelSync Error!!!!" notification.message = message notification.icon = initial.bundled_path(os.path.join('res', 'icon.ico')) notification.send(block=True)
def notify_msg(self): notification = Notify() notification.title = self.currency message = str(self.rate) + "@ \n" + self.time notification.message = message try: notification.audio = self.tone notification.icon = self.indicator notification.send(block=False) except ( exceptions.InvalidAudioFormat, exceptions.InvalidIconPath, exceptions.InvalidAudioPath, ): pass
def send_notification(title, text, icon_path): """Send notification out Args: title (str): Notification title text (str): Notification text icon_path (str): Path to icon shown in the notification """ notification = Notify() notification.title = title notification.message = text notification.application_name = 'NormCap ' + __version__ if icon_path: notification.icon = icon_path notification.send(block=False)
def notification(message: str) -> None: """ Sends a normal notification. Args: message (set): Message to send. """ if message is None or enable_notifications is False: return notification = Notify() notification.title = "LevelSync" notification.message = message notification.icon = initial.bundled_path(os.path.join('res', 'samuraisword.ico')) notification.send(block=True)
def notifcation(title="test", message="test"): notification = Notify() notification.title = title notification.message = message sound = random_sound() setting = read_config() if setting[2] == "True": # True False - SOUND ON OFF if setting[3] == "default": # default random notification.audio = "sounds/" + "default.wav" if setting[3] == "random": # default random notification.audio = "sounds/" + sound if setting[4] == "True": # True False - Norifcarion ON OFF notification.icon = "images/icon.png" notification.send()
def Three_Days_Notification(First, Last, Age, Birthday): Birthday = datetime.datetime.strptime(Birthday, "%Y-%m-%d") Day = Birthday.day Formatted = "th" if Day == 1 or Day == 21 or Day == 31: Formatted = "st" if Day == 2 or Day == 22: Formatted = "nd" if Day == 3 or Day == 23: Formatted = "rd" Birthday = Birthday.strftime(f"%B {Day}{Formatted}!") notification = Notify() notification.title = f"{First} {Last}'s Birthday is in 3 days!" notification.message = f"{First} turns {Age} years old on {Birthday}!" notification.icon = "Images\BirthdayCakeIcon.png" notification.application_name = "Birthday Tracker" notification.audio = r"Images\NotificationSound.wav" notification.send()
def send_notification(self, title, text, icon_path): """Send notification out. Args: title (str): Notification title text (str): Notification text icon_path (str): Path to icon shown in the notification """ try: notification = Notify() notification.title = title notification.message = text notification.application_name = "NormCap" if icon_path: notification.icon = icon_path notification.send(block=False) except BinaryNotFound: self._logger.warning( "Missing dependencies. Notifications will not" " be visible." ) if self._verbose: traceback.print_exc()
def _on_received_booster(self, pick_point: PickPoint, timeout: t.Optional[float], began_at: float) -> None: self.received_booster.emit(pick_point, timeout or 0., began_at) if self._pick_counter_head >= pick_point.global_pick_number: self._update_head( pick_point.global_pick_number, pick_point.global_pick_number > self._pick_number) if not Context.main_window.isActiveWindow( ) and settings.NOTIFY_ON_BOOSTER_ARRIVED.get_value(): try: notification = Notify() notification.title = 'New pack' notification.message = f'pack {pick_point.round.pack} pick {pick_point.pick_number}' notification.application_name = values.APPLICATION_NAME notification.icon = paths.ICON_PATH notification.send() except UnsupportedPlatform: Context.notification_message.emit( 'OS notifications not available') Context.settings.setValue('notify_on_booster_arrived', False)
def bilgilendir(): notification = Notify() notification.title = "Dolar Kuru" notification.message = "Dolar Beklenene ulasti. {} tl".format(dolartl) notification.icon = "dolarResim.jpg" notification.send()
def send_notification(self): notification = Notify() notification.title = "Grape tomato" notification.message = "Time's up!" notification.icon = "" notification.send()
# Creado ChepeCarlos de ALSW # Tutorial Completo en https://nocheprogramacion.com # Canal Youtube https://youtube.com/alswnet?sub_confirmation=1 from notifypy import Notify notification = Notify() notification.title = "Titulo" notification.message = "Hola Mundo" notification.icon = "/home/chepecarlos/1.Proyectos/1.Oficiales/1.NocheProgramacion/series/python/03_notificaciones_en_python/Python/LogoALSW.png" notification.send()
# Creado ChepeCarlos de ALSW # Tutorial Completo en https://nocheprogramacion.com # Canal Youtube https://youtube.com/alswnet?sub_confirmation=1 from os import path from notifypy import Notify notification = Notify() notification.title = "Titulo" notification.message = "Hola Mundo" icono = "LogoALSW.png" direcion = path.abspath(path.dirname(__file__)) notification.icon = path.join(direcion, icono) notification.send()
from notifypy import Notify #if not available, install with "pip3 install notify-py" from time import sleep from random import randint as rndint import os d = 20 #notification duration. (in minutes) notify = Notify() facts = [ "Only 1.1% of the water on earth is suitable for drinking as is.", "Our bodies consist of 55 – 75% water", "Depression and fatigue can often be symptoms of dehydration.", "Adult humans are 60 percent water, and our blood is 90 percent water.", "Water is essential for the kidneys and other bodily functions.", "When dehydrated, the skin can become more vulnerable to skin disorders and wrinkling.", "Drinking water instead of soda can help with weight loss.", "Children in the first 6 months of life consume seven times as much water per pound as the average American adult.", "Water is Part of a Deeply Interconnected System.", "A Person Can Only Live About a Week Without Water.", "Water Regulates the Earth's Temperature.", "Approximately 80% of your brain tissue is made of water" ] sleep(60 * 1) while (True): notify.title = "Water Reminder | Please drink a glass of water" randfacts = facts[rndint(0, len(facts) - 1)] notify.message = randfacts notify.icon = str(os.path.dirname(__file__)) + "/icon/icon.png" notify.send() sleep(60 * d)