我在試圖找到一種方法來顯示我正在爲GUI工作的谷歌搜索/ RSS FEED的標題,網址和時間戳列表。我遇到很多麻煩,試圖找到一種將結果以可讀形式排序的方法。任何文章或指導,至於做什麼將不勝感激!在tkinter中的Pprint
from tkinter import *
import urllib.request
import feedparser
from pprint import pprint
search_term = ('') #search term for url
quoted_search_term = urllib.parse.quote(search_term)
def go():
text.delete(1.0, END) #delete text
rss_string = 'https://news.google.com/news/section?output=rss'.format (quoted_search_term)
parsed_rss_string = feedparser.parse(rss_string) #assigning variable for parsed feed
text.insert(1.0, parsed_rss_string) #insert text of parsed feed
browser_window = Tk() #tk window
browser_window.title('RSS Feed') #Window title
label = Label(browser_window, text= 'Search:')
entry = Entry(browser_window)
button = Button(browser_window, text='Go', command = go)#Go Button
text = Text(browser_window) #results box
label.pack(side=TOP) #Positioning of search title
entry.pack(side=TOP) #Positioning of search box
button.pack(side=TOP)#Positioning of go
text.pack(side= RIGHT) #Positioning of text
browser_window.mainloop()
我不明白'pprint'必須做它正在寫入一個文本框,而不是打印。 –