我对 Python 还很陌生,并且已经开始构建一个显示新闻信息的 GUI。我创建了五个函数,当它们被调用时,会在窗口中显示相关信息。下面是函数本身的一个片段:
# first function which creates new labels and fills them with the relevant site pic,
# first article title, and description.
def fn1():
label_maker(infoFrame, 0, 0, 630, 389, image=newImage1,
background='red')
label_maker(infoFrame, 630, 0, 655, 389, text=entry1.title,
background='blue', font=("", 20), wraplength=600)
label_maker(infoFrame, 0, 389, 1286, 389, text=entry1.description,
wraplength=1250, font=("", 16),
background='green')
# second function to create labels and fill them with relevant info
def fn2():
label_maker(infoFrame, 0, 0, 630, 389, image=newImage2,
background='red')
label_maker(infoFrame, 630, 0, 655, 389, text=entry2.title,
background='blue', font=("", 20), wraplength=600)
label_maker(infoFrame, 0, 389, 1286, 389, text=entry2.description,
wraplength=1250, font=("", 16),
background='green')
# third
def fn3():
label_maker(infoFrame, 0, 0, 630, 389, image=newImage3,
background='red')
label_maker(infoFrame, 630, 0, 655, 389, text=entry3.title,
background='blue', font=("", 20), wraplength=600)
label_maker(infoFrame, 0, 389, 1286, 389, text=entry3.description,
wraplength=1250, font=("", 16),
background='green')
# fourth
def fn4():
label_maker(infoFrame, 0, 0, 630, 389, image=newImage4,
background='red')
label_maker(infoFrame, 630, 0, 655, 389, text=entry4.title,
background='blue', font=("", 20), wraplength=600)
label_maker(infoFrame, 0, 389, 1286, 389, text=entry4.description,
wraplength=1250, font=("", 16),
background='green')
我想以某种方式循环运行这些函数中的每一个,其中一个函数运行约 15 秒,然后运行下一个,然后运行下一个,依此类推,直到窗口关闭。我已经尝试过使用该after()方法,但它以我使用它的方式运行,直到最后一个函数被调用,函数才显示任何内容。我怎样才能一个接一个地循环这些并实际让它们显示相关信息?
千巷猫影
相关分类