Guest User

Untitled

a guest
Jul 28th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. #!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3
  2. # -*- coding: utf-8 -*-
  3.  
  4. from tkinter import *
  5. import time
  6. import urllib.request
  7. from bs4 import BeautifulSoup
  8. import threading
  9. from queue import Queue
  10.  
  11. data = None
  12.  
  13. class httpReq(threading.Thread):
  14. def run(self):
  15.  
  16. global data
  17.  
  18. while True:
  19. url = "https://twitter.com/realDonaldTrump"
  20. page = urllib.request.urlopen(url)
  21. soup = BeautifulSoup(page, "html.parser")
  22. data = soup.title.text
  23. print(data)
  24.  
  25. x = httpReq()
  26. x.start()
  27.  
  28. class Example(Frame):
  29.  
  30. global data
  31.  
  32. def __init__(self, parent):
  33. Frame.__init__(self, parent)
  34. self.parent = parent
  35. self.initUI()
  36.  
  37. def initUI(self):
  38. self.parent.title("Example App")
  39. self.pack(fill=BOTH, expand=True)
  40.  
  41. frame1 = Frame(self)
  42. frame1.pack(fill=X)
  43.  
  44. lbl1 = Label(frame1, text="DATA", width= 20)
  45. lbl1.pack(side=LEFT, padx=5, pady=5)
  46.  
  47. lbl2 = Label(frame1, text= data)
  48. lbl2.pack(fill=X, padx=5, expand=True)
  49.  
  50. def main():
  51. root = Tk()
  52. root.geometry("1920x1080")
  53. app = Example(root)
  54. root.mainloop()
  55.  
  56. if __name__ == '__main__':
  57. main()
Add Comment
Please, Sign In to add comment