Using TKinter to show popular tweets from twitter API (Tweepy)

unihno at gmail.com unihno at gmail.com
Wed Apr 5 15:48:54 EDT 2017


hello 
I'm building a python app where it should show the popular tweets in boxex in line with each other using TKinter. The problem is that the labels of the tweets are showing at the bottom of each other and i want them to be in boxes like this:

---- ---- ---- ---- 
|  | |  | |  | |  |
---- ---- ---- ---- 
---- ---- ---- ---- 
|  | |  | |  | |  |
---- ---- ---- ---- 
---- ---- ---- ---- 
|  | |  | |  | |  |
---- ---- ---- ---- 

this is my code:

from Tkinter import *
import tweepy
from local import *
import Tkinter as tk

auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
api = tweepy.API(auth)
sa_ID = 23424938
large_text_size = 12
text_size = 20

#create obj in the root page (main windows)
root= Tk()
root.title("The news Portal")
root.configure(background='black')
trends1 = api.trends_place(id=sa_ID)
data = trends1[0]
# grab the trends
trends = []
trends=data['trends']
for trend in trends:
    if trend['name'].startswith('#'):
        for status in tweepy.Cursor(api.search, q=trend['name'], result_type='popular').items(1):
            f = tk.Frame(root, background='black', borderwidth=2, relief="groove").pack()
            Label(text=('@' + status.user.screen_name, "tweeted: ",status.text)).pack()

root.mainloop()



please help.



More information about the Python-list mailing list