Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3
- # -*- coding: utf-8 -*-
- from tkinter import *
- import time
- import urllib.request
- from bs4 import BeautifulSoup
- import threading
- from queue import Queue
- data = None
- class httpReq(threading.Thread):
- def run(self):
- global data
- while True:
- url = "https://twitter.com/realDonaldTrump"
- page = urllib.request.urlopen(url)
- soup = BeautifulSoup(page, "html.parser")
- data = soup.title.text
- print(data)
- x = httpReq()
- x.start()
- class Example(Frame):
- global data
- def __init__(self, parent):
- Frame.__init__(self, parent)
- self.parent = parent
- self.initUI()
- def initUI(self):
- self.parent.title("Example App")
- self.pack(fill=BOTH, expand=True)
- frame1 = Frame(self)
- frame1.pack(fill=X)
- lbl1 = Label(frame1, text="DATA", width= 20)
- lbl1.pack(side=LEFT, padx=5, pady=5)
- lbl2 = Label(frame1, text= data)
- lbl2.pack(fill=X, padx=5, expand=True)
- def main():
- root = Tk()
- root.geometry("1920x1080")
- app = Example(root)
- root.mainloop()
- if __name__ == '__main__':
- main()
Add Comment
Please, Sign In to add comment