0
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)

I believe you already have an idea what I'm trying to do here. i parsed data using facebook graph api and now i want to print that data inside listbox or messagebox of GUI Application but everytime I run this application i get this

PATH, error: line 27, in listbox.insert(0, finalPost) AttributeError: 'NoneType' object has no attribute 'insert'

1 Answers1

0

geometry manager grid returns None:

replace:

listbox = Text(window, width = 50, height = 25, wrap = WORD, background ='White').grid(row = 0, column = 1)

with:

listbox = Text(window, width = 50, height = 25, wrap = WORD, background ='White')
listbox.grid(row = 0, column = 1)
Reblochon Masque
  • 35,405
  • 10
  • 55
  • 80
  • thank you but it did not work now I'm getting this error , hope you can fix it line 26, in listbox.insert(0, finalPost) File "C:\Users\Zaidan\AppData\Local\Programs\Python\Python36\lib\tkinter\__init__.py", line 3269, in insert self.tk.call((self._w, 'insert', index, chars) + args) _tkinter.TclError: character U+1f602 is above the range (U+0000-U+FFFF) allowed by Tcl [Finished in 1.5s] – Zaidan Chaudhary Aug 13 '18 at 10:33
  • This is a problem that comes from the characters in your text; they are outside the range handled by Tcl. You need to modify the text you want to manipulate so it conforms to what Tcl can handle. There is nothing else that I or you can do. As far as your problem is concerned, the `AttributeError: 'NoneType' object has no attribute 'insert'` was solved. – Reblochon Masque Aug 13 '18 at 10:47