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 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 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 _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 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 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 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 _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 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()
#!/usr/bin/python """Linux script created by Sonickyle27. This takes text within quotes and sends it to DeepL to be translated. You need an API key from DeepL that you can get from https://www.deepl.com/pro#developer""" import argparse, requests, json from notifypy import Notify apikey='77b8102f-d342-f26f-2fac-6daadae08d25' # Put your API key here! This is an example! # Look at https://www.deepl.com/docs-api/translating-text/request/ for supported languages sourcelang='JA' targetlang='EN' notification=Notify() notification.application_name=("DeepL script - "+sourcelang+" - "+targetlang) parser = argparse.ArgumentParser("command") parser.add_argument("input_string", help="The string that you would like to be translated", type=str) args = parser.parse_args() if sourcelang == 'JA': preparedsource=args.input_string.replace(" ", "") print("Input string without spaces:", preparedsource) else: preparedsource=args.input_string print("Input string:", preparedsource) url = ('https://api.deepl.com/v2/translate?auth_key='+apikey+'&text='+preparedsource+'&target_lang='+targetlang+'&source_lang='+sourcelang) rawresponse = requests.post(url) print(rawresponse) if rawresponse.status_code == 200: print("Translation: "+rawresponse.json()['translations'][0]['text']) notification.title = "Sucessfully translated" notification.message = ("Source: "+preparedsource+"\nTranslation: "+rawresponse.json()['translations'][0]['text']) notification.send() exit
def send_desktop_notification(message): notification = Notify() notification.application_name = 'pyfilesync' notification.title = 'File updated' notification.message = message notification.send()
from notifypy import Notify notification = Notify() notification.title = "Moshi Moshi" notification.message = "This is a message." notification.icon = "../logo-rass.png" notification.application_name = "Nofication from Rass" notification._notification_icon = "../logo-rass.png" notification.send()
def notify(usernames: Dict[str, str], a: Presence, boot: bool): thestring = "" theicon = "robloxnotif.ico" thecolor = Fore.WHITE thesound = "robloxnotif" if usernames[str(a.userId)].startswith("!") or usernames[str( a.userId)].startswith("[!]"): thesound = "fav" if str(a.userPresenceType) == str(PresenceType.Playing.value): thestring = "playing: " + a.lastLocation if a.lastLocation == "": thestring = "playing something" theicon = "playing" thecolor = Fore.LIGHTGREEN_EX # better for powershell elif str(a.userPresenceType) == str(PresenceType.Online.value): thestring = "online" theicon = "online" thecolor = Fore.LIGHTCYAN_EX # better for powershell elif str(a.userPresenceType) == str(PresenceType.InStudio.value): thestring = "in studio: " + a.lastLocation if a.lastLocation == "": thestring = "in studio making something" theicon = "studio" thecolor = Fore.LIGHTYELLOW_EX # better for powershell elif (str(a.userPresenceType) == str( PresenceType.Offline.value)) and (not boot): thestring = "now offline" thecolor = Fore.LIGHTBLACK_EX # better for powershell theicon = "offline" if thestring != "": log(usernames[str(a.userId)] + " is " + thestring, thecolor) if thePlatform == "Linux" or thePlatform == "Darwin": from notifypy import Notify notif = Notify() notif.title = usernames[str(a.userId)] + " is" notif.message = thestring notif.icon = f"./icons/png/{theicon}.png" notif.audio = path.realpath(f"./sounds/{thesound}.wav") notif.application_name = "robloxnotif" notif.send(block=True) elif thePlatform == "Windows": import win10toast from playsound import playsound toast = win10toast.ToastNotifier() toast.show_toast( usernames[str(a.userId)] + " is", thestring, duration=3, icon_path="./icons/" + theicon + ".ico", threaded=True, sound=False, ) try: playsound(path.realpath(f"./sounds/{thesound}.wav")) except UnicodeDecodeError: pass while toast.notification_active(): sleep(0.1)