Feb-21-2017, 11:22 AM
I am creating a display with my friend to display some information on a screen. He is coding the information (like a clock, and newsfeed and stuff like that) while I am displaying it. So he gives me scripts and I am combining them into one script basically. The problem is I am very new to python and cannot figure out how to add this particular script to mine. Here are the two scripts in full with mine first and the one I want to add to mine next (There are two places in the scripts which you may not have, there is the background picture I am using (0.png) and there is also supposed to be a link to a news api in the other script but the site wont let me post it. If you are running it you will have to insert the bbc news api into that place.):
from tkinter import * from PIL import ImageTk, Image import os import time import requests import tkinter as tk class App(tk.Tk): def __init__(self): # call the __init__ method of Tk class to create the main window tk.Tk.__init__(self) # background image img = ImageTk.PhotoImage(Image.open("0.png")) panel = Label(self, image=img) panel.pack() # clock self.label = tk.Label(self, text="", font=('comic',50,'bold'), bg='#464545', fg='#1681BE') self.label.place(height=204, width=484, x=1384, y=824) self.update_clock() # window geometry w, h = self.winfo_screenwidth(), self.winfo_screenheight() self.geometry("%dx%d+0+0" % (w, h)) self.overrideredirect(True) self.mainloop() def update_clock(self): now = time.strftime('%H:%M:%S') self.label.configure(text=now) self.after(1000, self.update_clock) app = App()
import requests import tkinter as tk response = requests.get("this is a link to the news api") data = response.json() Run = "" for item in data ['articles']: Run +=(item["description"]+ " ") root = tk.Tk() deli = 100 # milliseconds of delay per character svar = tk.StringVar() labl = tk.Label(root, textvariable=svar, height=10 ) def shif(): shif.msg = shif.msg[1:] + shif.msg[0] svar.set(shif.msg) root.after(deli, shif) shif.msg = Run shif() labl.pack() root.mainloop()I don't quite know how the class function works and I'm having trouble combining them around that. Thank you for any help and ask me anything I didn't include.