Skip to content

Commit

Permalink
Working notification
Browse files Browse the repository at this point in the history
  • Loading branch information
sksshouvo committed Nov 24, 2023
1 parent 9c7ee8c commit 8bc94bb
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 45 deletions.
Binary file modified databases/rss_feed.db
Binary file not shown.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ tksheet==6.2.9
icecream==2.1.3
plyer==2.1.0
playsound==1.3.0
desktop-notifier==3.5.6
34 changes: 9 additions & 25 deletions views/test.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,12 @@
import tkinter as tk
from tksheet import Sheet
import asyncio
from desktop_notifier import DesktopNotifier

notifier = DesktopNotifier()

class demo(tk.Tk):
def __init__(self):
tk.Tk.__init__(self)
self.grid_columnconfigure(0, weight = 1)
self.grid_rowconfigure(0, weight = 1)
self.frame = tk.Frame(self)
self.frame.grid_columnconfigure(0, weight = 1)
self.frame.grid_rowconfigure(0, weight = 1)
self.sheet = Sheet(self.frame,
data = [
[
f"Row {r}, Column {c}\nnewline1\nnewline2"
for c in range(50)
]
for r in range(500)
]
)
self.sheet.enable_bindings()
self.frame.grid(row = 0, column = 0, sticky = "nswe")
self.sheet.grid(row = 0, column = 0, sticky = "nswe")
async def main():
n = await notifier.send(title="Hello world!", message="Sent from Python")
await asyncio.sleep(5) # wait a bit before clearing notification
await notifier.clear(n) # removes the notification
await notifier.clear_all() # removes all notifications for this app


app = demo()
app.mainloop()
asyncio.run(main())
28 changes: 8 additions & 20 deletions views/view.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import webbrowser

import tkinter
import tkinter.font as tkFont
from tkinter import messagebox

from classes.rss_feed import rss_feed_class
from classes.validation import Validation
from config import settings
from model.rss_feed_model import RssFeedModel
from classes.notifier.test_notifications import LinuxNotificationHandler
from classes.notifications import NotificationHandler
from tkinter import messagebox
import threading
import tkinter
import tkinter.font as tkFont
import webbrowser


class View:
Expand Down Expand Up @@ -46,10 +42,11 @@ def on_select(self, event):
webbrowser.open_new_tab(link)

def on_start_button_click(self, link_input, interval):
self.start_button.config(text="Running", state="disabled")
self.stop_button.config(text="Stop", state="normal")

self.start_action(link_input, interval)

self.start_button.config(text="Running", state="disabled")
self.stop_button.config(text="Stop", state="normal")

def start_action(self, link_input, interval):
rss_feed_fetcher = rss_feed_class()
Expand All @@ -72,7 +69,7 @@ def start_action(self, link_input, interval):
self.listbox.place(x=20, y=190, width=750)
new_rss_feeds = []
old_rss_feeds = []
# new_rss_feed_count = 0

for index, feed_data in enumerate(self.rss_feed_data[:self.initial_show_limit], start=1):
data_set = f"{index}\t -\t {feed_data[1]}"
if not rss_feed_model.check_for_new_data(link=feed_data[2]):
Expand All @@ -87,15 +84,6 @@ def start_action(self, link_input, interval):
for data in full_data_set:
self.listbox.insert(tkinter.END, data)

notification_handler = NotificationHandler(self.root)
notification_handler.handle_notifications(new_rss_feeds)
# threading.Thread(target=notification_handler.handle_notifications, args=[new_rss_feeds])

# lnh = LinuxNotificationHandler()
# lnh.show_notification("Title", "NEw message")

# Notification.get_notification(new_rss_feed_count)

new_rss_feed_count = 0
self.listbox.bind("<<ListboxSelect>>", self.on_select)
self.schedule_refresh(link_input, interval)
Expand Down

0 comments on commit 8bc94bb

Please sign in to comment.