A tutorial on using the twitter api in python:
Code:
from twitter import *
from tkinter import *
def showTweets(x, num):
display a number of new tweets and usernames
for i in range(0, num):
line1 = (x[i]['user']['screen_name'])
line2 = (x[i]['text'])
w = Label(master, text=line1 + "\n" + line2 + "\n\n")
w.pack()
def getTweets():
x = t.statuses.home_timeline(screen_name="putscreennamehere")
return x
def tweet():
global entryWidget
if entryWidget.get().strip() == "":
print("Empty")
else:
t.statuses.update(status=entryWidget.get().strip())
entryWidget.delete(0,END)
print("working")
Put in token, token_key, con_secret, con_secret_key
t = Twitter(
auth=OAuth('', '',
'', ''))
numberOfTweets = 10
master = Tk()
showTweets(getTweets(), numberOfTweets)
master.title("Tkinter Entry Widget")
master["padx"] = 40
master["pady"] = 20
Create a text frame to hold the text Label and the Entry widget
textFrame = Frame(master)
#Create a Label in textFrame
entryLabel = Label(textFrame)
entryLabel["text"] = "Make a new Tweet:"
entryLabel.pack(side=LEFT)
Create an Entry Widget in textFrame
entryWidget = Entry(textFrame)
entryWidget["width"] = 50
entryWidget.pack(side=LEFT)
textFrame.pack()
button = Button(master, text="Submit", command=tweet)
button.pack()
master.mainloop()
more info in twitter API: https://pypi.python.org/pypi/twitter
On this page of the site you can watch the video online How to user the Twitter API in python with a duration of hours minute second in good quality, which was uploaded by the user MineIsPolo 19 April 2016, share the link with friends and acquaintances, this video has already been watched 25,966 times on youtube and it was liked by 99 viewers. Enjoy your viewing!