Kivy 标签只显示文本循环的最后一个元素

我正在使用 Feedparser 来获取 RSS 新闻并显示新闻标题


import feedparser

import kivy

kivy.require('1.0.6') # replace with your current kivy version !


from kivy.app import App

from kivy.uix.label import Label



class MyApp(App):


 def build(self):

    d=feedparser.parse('https://en.wikinews.org/w/index.php?title=Special:NewsFeed&feed=rss&categories=Published&notcategories=No%20publish%7CArchived%7cAutoArchived%7cdisputed&namespace=0&count=15&ordermethod=categoryadd&stablepages=only')

    print (len(d['entries']))

    for post in d['entries']:

        news=post.title

        print(news)

    return Label(text=news)



if __name__ == '__main__':

    MyApp().run()

即news=post.title使用 kivy 标签。


原来的输出如下:


Study suggests Mars hosted life-sustaining habitat for millions of years

NASA's TESS spacecraft reports its first exoplanet

Russians protest against pension reform

US rapper Mac Miller dies at home in Los Angeles

Creativity celebrated at Fan Expo Canada 2018 in Toronto

Brisbane, Australia Magistrates Court charges two cotton farmers with $20m fraud  

Fossil genome shows hybrid of two extinct species of human

Singer Aretha Franklin, 'queen of soul', dies aged 76

New South Wales, Australia government says entire state in winter 2018 drought

Real Madrid agrees with Chelsea FC to sign goalkeeper Thibaut Courtois

但是,每当我运行程序时,Kivy 应用程序只显示循环中的最后一个标题


IE:Real Madrid agrees with Chelsea FC to sign goalkeeper Thibaut Courtois


关于我缺少什么的任何想法?任何帮助将不胜感激。


慕标5832272
浏览 134回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python