from tkinter import *
import json
import requests
accessToken = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx'
query = r'xxxxxxx/?fields=posts.limit(20)'
window = Tk()
window.title('The Sakht Launday')
pagePicture = PhotoImage(file= 'pagePicture.GIF')
Label (window, image = pagePicture).grid(row = 0, column = 0, sticky = 'E')
#Text To Display Inside
listbox = Text(window, width = 50, height = 25, wrap = WORD, background ='White').grid(row = 0, column = 1)
reQ = requests.get('https://graph.facebook.com/v3.1/' + query, {'access_token': accessToken})
tempData = reQ.json()
json.dumps(tempData)
data = tempData['posts']['data']
for results in data:
caption = results['message']
timeUploaded = results['created_time']
urlID = results['id']
finalPost = 'Caption: {0}\nTime Uploaded: {1}\nURL: {2}\n\n'.format(caption, timeUploaded, urlID)
listbox.insert(0, finalPost)
我相信您已经知道我要在这里做什么。我使用facebook graph api解析了数据,现在我想在GUI应用程序的列表框或消息框中打印该数据,但是每次运行此应用程序时,我都会得到
PATH,错误:第27行,在 listbox.insert(0,finalPost) AttributeError:“ NoneType”对象没有属性“插入”
答案 0 :(得分:0)
几何管理器grid
返回None:
替换:
listbox = Text(window, width = 50, height = 25, wrap = WORD, background ='White').grid(row = 0, column = 1)
具有:
listbox = Text(window, width = 50, height = 25, wrap = WORD, background ='White')
listbox.grid(row = 0, column = 1)