Code as promised. Please don't laugh! (My task bar is at the bottom of the screen). The screenshot is at the top of the screen.
Code:
# rsstkinter.py# M Hollingworth# 13-Feb-2021## RUN WITH PYTHON3## Pre-requisite "sudo pip3 install feedparser"import sysif sys.version_info[0] < 3 :from Tkinter import *else :from tkinter import *import feedparserimport timefrom vcgencmd import VcgencmdfeedNews = "http://feeds.bbci.co.uk/news/rss.xml?edition=uk"feedScience = "http://feeds.bbci.co.uk/news/science_and_environment/rss.xml"feedTech = "http://feeds.bbci.co.uk/news/technology/rss.xml"feedSport = "http://feeds.bbci.co.uk/sport/rss.xml"strFeedData = ""strCurrentFeed = feedNewsblnFirstGet = TruetextColour = 0def getFeed() :global strFeedDataglobal blnFirstGetstrFeedData = ""strX = feedparser.parse(strCurrentFeed)for i in range(len(strX)):try :strFeedData = strFeedData + strX['entries'][i]['title']except :strFeedData = strFeedData + " [ - ] "strFeedData = strFeedData + " //:// "blnFirstGet = Truedef getThrottledState() :global textColourvcgm = Vcgencmd()jsonDict = vcgm.get_throttled()#print(jsonOutput)v = jsonDict['breakdown']['0']v1 = jsonDict['breakdown']['0']#print(v)if (v == True) or (v1 == True) :labelX.configure(fg='red')else :labelX.configure(fg='black')def updateFeed() :global strFeedDataglobal blnFirstGet# Take the first x charactersstrX = strFeedData[:295]labelX.configure(text=strX)if len(strFeedData) > 295 :# Grab the first characterstrX = strFeedData[0] # Grab everything except the first characterstrY = strFeedData[1:]strFeedData = strY + strX if blnFirstGet == True :blnFirstGet = Falseroot.after(2000, updateFeed)else :root.after(100, updateFeed)def keyDown(e) :global strCurrentFeedif e.char == 's' :strCurrentFeed = feedScienceif e.char == 'n' :strCurrentFeed = feedNewsif e.char == 't' :strCurrentFeed = feedTechif e.char == 'f' :strCurrentFeed = feedSportif e.char == 'q' :root.destroy()getFeed()getThrottledState()# Detect a mouse down event on the window and set it's focus so we can interact by using the kbddef button(e) :root.focus_force()# And update the current feedgetFeed()# Start of the main codegetFeed()root=Tk()# Set to full width of my screen and 1 line (Tkinter default font) deeproot.geometry("1920x20")# Set to top left hand edge of screenroot.geometry("+0+0")# Remove the title bar and resize buttonsroot.wm_attributes("-type", "dock")root.focus_force()root.bind("<KeyPress>", keyDown)root.bind("<Button>", button)labelX=Label(root, text="", fg='black')labelX.grid(row=0, column=0, rowspan=1)root.resizable(False, False)getThrottledState()updateFeed()root.mainloop()
Statistics: Posted by MarkDH102 — Mon Apr 22, 2024 6:02 am