class Pomodoro: def __init__(self): self.toaster = ToastNotifier() def task(self, timing=1500): print("starting task...") time.sleep(timing) self.toaster.show_toast("POMODORO", "Your task has completed!", threaded=True, icon_path=None, duration=3) # Await toaster completion while self.toaster.notification_active(): time.sleep(0.1) return def short_break(self, timing=300): print("starting break...") time.sleep(timing) self.toaster.show_toast("POMODORO", "Short break is over!", threaded=True, icon_path=None, duration=3) # Await toaster completion while self.toaster.notification_active(): time.sleep(0.1) return def medium_break(self, timing=1800): print("starting break...") time.sleep(timing) self.toaster.show_toast("POMODORO", "Medium break is over!", threaded=True, icon_path=None, duration=3) # Await toaster completion while self.toaster.notification_active(): time.sleep(0.1) return def long_break(self, timing=3600): print("starting break...") time.sleep(timing) self.toaster.show_toast("POMODORO", "Long break is over!", threaded=True, icon_path=None, duration=3) # Await toaster completion while self.toaster.notification_active(): time.sleep(0.1) return
def window_notify(): from win10toast import ToastNotifier toaster = ToastNotifier() toaster.show_toast( "Weather Report", f"""Name: {name}\nHumidity: {humid}\nSpeed: {speed}\nTemperature: {temp}""", threaded=True, icon_path="weather.ico", duration=3) toaster.notification_active()
def get_weather_data(): toaster = ToastNotifier() owm = pyowm.OWM("6a64010047bb47bcde87e6191871fc02") obs = owm.weather_at_place("Exeter,uk") w = obs.get_weather() wind = w.get_wind() humidity = w.get_humidity() rain = w.get_rain() temp = w.get_temperature("celsius") tomorrow = pyowm.timeutils.tomorrow() temperature_now = temp["temp"] wind_now = wind["speed"] if len(rain) == 0: rain = "no rain in your area now" time = datetime.datetime.now() weather_data = "the temperature now is: " + str( temperature_now) + " °C" + " the wind speed is: " + str( wind_now) + " MPH" + " the current humidity is " + str( humidity) + "%" + " the current rain fall is" + str( rain) + "%" + str(time) print(weather_data) toaster.show_toast("weather data now in your location", weather_data, icon_path=None, duration=10, threaded=True) while toaster.notification_active(): time.sleep(0.1)
def sy_hello(): comp_name = os.path.expanduser('~') try: with open(r'C:\Users\{}\Desktop\VoiceAssistant\userDatas\userData.txt'. format(comp_name[9:]), 'r', encoding='utf-8') as file: data = [line.strip() for line in file] except: talkUS( "Please check user data.txt something went wrong please try again." ) try: talkUS(random.choice(commandss.merbdonus) + " " + data[0]) toaster = ToastNotifier() toaster.show_toast( "Assistant Says:", "Hello To You!", icon_path=r"C:\Users\{}\Desktop\VoiceAssistant\icons\notif.ico". format(comp_name[9:]), duration=8) while toaster.notification_active(): time.sleep(0.1) except: talkUS( "Sorry ı don't know your name please add your name in user data.txt as a first data." )
def notify(title, text, **kwargs): sound = kwargs.get('sound', None) subtitle = kwargs.get('subtitle', None) duration = kwargs.get('duration', 5) if os.name == 'posix': if subtitle != None: os.system(""" osascript -e 'display notification "{}" with title "{}" subtitle "{}" sound name "{}"' """.format(text, title, subtitle, sound)) else: os.system(""" osascript -e 'display notification "{}" with title "{}" sound name "{}"' """.format(text, title, subtitle, sound)) if os.name == 'nt': toaster = ToastNotifier() if subtitle != None: toaster.show_toast(title, "{} - {}".format(subtitle, text), duration=duration) else: toaster.show_toast(title, "{}".format(text), duration=duration) while toaster.notification_active(): time.sleep(0)
def Notify(status,txt): toaster=ToastNotifier() toaster.show_toast(status,txt, icon_path='icon.ico', duration=10, threaded=True) while toaster.notification_active(): time.sleep(0.1)
def notify(): db = firestore.client() Eye_ref = db.collection('EyeMovement') query = Eye_ref.order_by('time', direction=firestore.Query.DESCENDING).limit(1) results = query.stream() last_doc = list(results)[-1].to_dict() time_on = last_doc['time'] counter = last_doc['contactCounter'] time_counter = last_doc['counter'] # One-time initialization toaster = ToastNotifier() if counter >= 4636: toaster.show_toast("Notification!", "You have been watching the screen for 40 minutes, take a 5-10 min break off screen", threaded=True, icon_path=None, duration=3) # 3 seconds # if counter >= 4636: # toaster.show_toast("Notification!", "You have been watching the screen for 40 minutes, take a 5-10 min break off screen", threaded=True, # icon_path=None, duration=3) # 3 seconds # Show notification whenever needed # To check if any notifications are active, # use `toaster.notification_active()` import time while toaster.notification_active(): time.sleep(0.1)
def mic_test(): while 1: with sr.Microphone() as source: print("-") r.adjust_for_ambient_noise(source) audio = r.listen(source) print("-") try: wordseq = r.recognize_google(audio) if any(s in wordseq.lower() for s in recog_list): print("JARVIS ACTIVATED") with sr.Microphone() as source: print("-") r.adjust_for_ambient_noise(source) audio = r.listen(source) print("-") wordseq = r.recognize_google(audio) print(wordseq) try: wordseq_tokens = wordseq.lower().split() print(wordseq_tokens) # build sentiment analysis here rake = Rake() rake.extract_keywords_from_text(wordseq) keywords = rake.get_ranked_phrases() print(keywords) # analyze sentiment and execute for k_word in keywords: if k_word == "time": print("The time right now is 11:43 pm") elif k_word == "open": # file search s.call("D:\\osu\\osu!.exe") elif k_word == "remind": if platform == "linux" or platform == "linux2" or platform == "darwin": s.call( ["notify-send", "INSERT_MSG_HERE"]) elif platform == "win32": toaster = ToastNotifier() toaster.show_toast( "This is your reminder to: ", duration=10) while toaster.notification_active(): time.sleep(0.1) except: print("Error occurred in obtaining the tokens") else: print("Please activate Jarvis") except sr.UnknownValueError: print("Jarvis deactivated, please call on it to reactive it") except sr.RequestError as e: print( "Could not request results from Google Speech Recognition service; {0}".format(e))
def notify_ts_prices(highS, lastS, lowS, highO, lastO, lowO): toaster = ToastNotifier() toaster.show_toast("TurtleCoin Prices (TradeSatoshi)", str(highS) + str(lastS) + str(lowS), icon_path="TRTL.ico", duration=5) while toaster.notification_active(): time.sleep(0.1)
def ShowNotification(title, description, delay =2): toaster = ToastNotifier() toaster.show_toast(title, description, icon_path=None, duration=delay, threaded=True) while toaster.notification_active(): time.sleep(0.1)
def notify_to_prices(highS, lastS, lowS, highO, lastO, lowO): toaster = ToastNotifier() toaster.show_toast("TurtleCoin Prices (TradeOgre)", highO + lastO + lowO, icon_path="TRTL.ico", duration=5) while toaster.notification_active(): time.sleep(0.1)
def make_toast(self,cur_location,date_time,other): toaster = ToastNotifier() loc = "Shipment @ {}".format(cur_location) stat = " - ".join(date_time + other) toaster.show_toast(loc, stat, icon_path="python.ico" ,duration=5, threaded=True) while toaster.notification_active(): for f, l in self.crazzy_frog: winsound.Beep(int(f), int(l))
def notif_listening(): toaster = ToastNotifier() toaster.show_toast("Ferdinand", "I'm listening to you !", icon_path="media/ferdinand.ico", duration=3, threaded=True) while toaster.notification_active(): time.sleep(0.1)
def notification(heading="", text="", duration=5): toaster = ToastNotifier() toaster.show_toast(heading, text, icon_path='joystick-32.ico', duration=5, threaded=True) while toaster.notification_active(): time.sleep(0.1)
def create_noti(mission_title, mission_info): toaster = ToastNotifier() toaster.show_toast(title=mission_title, msg=mission_info, icon_path="./my_logo.ico", duration=15, threaded=True) while toaster.notification_active(): time.sleep(0.1)
def notification(icon, stime): toaster = ToastNotifier() toaster.show_toast("KmTorrent", "Download complete", icon_path=icon, duration=stime) while toaster.notification_active(): time.sleep(0.1)
def notifyWindows(urlName: str): toaster = ToastNotifier() toaster.show_toast("Top Hat Question!", "New question on " + urlName, icon_path=None, duration=8, threaded=True) while toaster.notification_active(): time.sleep(0.1)
def weather_toast(location="N/A", temperature="N/A", description="N/A"): toaster = ToastNotifier() toaster.show_toast("Wetterbericht", "Es sind derzeit " + temperature + " °C in " + location + "\r\n" + description, icon_path='sun-2-32.ico', duration=5, threaded=True) while toaster.notification_active(): time.sleep(0.1)
def notif_problem(): toaster = ToastNotifier() toaster.show_toast( "Ferdinand", "I didn't understand what you said, please retry or check the language.", icon_path="media/ferdinand.ico", duration=3, threaded=True) while toaster.notification_active(): time.sleep(0.1)
def notif_no_mode(): toaster = ToastNotifier() toaster.show_toast( "Ferdinand", "Please choose between the clipboard and the write mode.", icon_path="media/ferdinand.ico", duration=3, threaded=True) while toaster.notification_active(): time.sleep(0.1)
def alert(item): # One-time initialization toaster = ToastNotifier() # Show notification whenever needed toaster.show_toast(item, "Easy Homes!", threaded=True, icon_path=None, duration=7) # 3 seconds while toaster.notification_active(): time.sleep(0.1)
def win10Mes2(unlocktime, locktime): toaster = ToastNotifier() # 采用自己的线程,这里图标不能使用相对路径,因为UseCemera.py已经更改路径。 toaster.show_toast("解锁提示", "锁定时间:"+locktime+"\n解锁时间:"+unlocktime, icon_path=r"D:\PythonPro\FStudy\ZTheUsage\monitorPC\damon.ico", duration=10, threaded=True) # 等待提示框关闭 while toaster.notification_active(): time.sleep(0.1)
def main(): readedVar = read() writedVar = write() if readedVar == writedVar: print("Все нормально!") else: toaster = ToastNotifier() toaster.show_toast("Обновление!", "В базе данных новая заявка! Следует проверить!", threaded=True, icon_path=None, duration=7) while toaster.notification_active(): time.sleep(0.1)
def Notify(MessageTitle, MessageBody): toaster = ToastNotifier() toaster.show_toast(MessageTitle, MessageBody, icon_path="logo.ico", duration=3, threaded=True) from playsound import playsound playsound('Notification2.mp3') while toaster.notification_active(): time.sleep(0.1)
def setnotification(): toaster = ToastNotifier() toaster.show_toast( "It has been 20 min since you have looked away from your computer!!!", "Please blink your eyes for sometime !!", icon_path="eye.ico", duration=10) # Wait for threaded notification to finish while toaster.notification_active(): time.sleep(0.1)
def showToastNotification(self, mainText, subText, iconPath): toaster = ToastNotifier() toaster.show_toast(mainText, subText, icon_path=iconPath, duration=5, threaded=True) # Wait for threaded notification to finish while toaster.notification_active(): time.sleep(0.3)
def notificar(self, titulo, mensaje): toaster = ToastNotifier() toaster.show_toast(titulo + "!", mensaje, threaded=True, icon_path=None, duration=6) while toaster.notification_active(): time.sleep(0.1)
def minuteEvent(): for event in toDoEvents.values(): if event.remind_time.strftime("%m/%d/%Y, %I:%M") == datetime.now( ).strftime("%m/%d/%Y, %I:%M"): toaster = ToastNotifier() toaster.show_toast(event.title, event.description, threaded=True, icon_path=None, duration=8) while toaster.notification_active(): time.sleep(0.1)
def playSound(): from playsound import playsound from win10toast import ToastNotifier playsound('[location]\\src\\1.wav') toaster = ToastNotifier() toaster.show_toast("Task Manager", "Its Time to Do Your Work", icon_path="[location]\\src\\icon.ico", duration=10) import time while toaster.notification_active(): time.sleep(0.1)
class WinBibleVerseDisplay(BibleVerseDisplay): def __init__(self): self.toaster = ToastNotifier() def display_verse(self, reference, passage_text, duration): self.toaster.show_toast(reference, passage_text, duration=duration, icon_path="python.ico", threaded=True) def active(self): return self.toaster.notification_active()