from tkinter import *
import fnd
from fnd import fake_news
import infer
def find_news():
global e
string = e.get()
ans=infer.fake_fake(string)
if(ans==0):
w = Label(window, text="FAKE",bg="red",fg="white",font="none 19 bold")
w.pack()
else:
w= Label(window,text="REAL",bg="green",fg="white",font="none 19 bold")
w.pack()
window = Tk()
window.title('AVIS')
window.geometry("500x500")
window.configure(background='black')
l1=Label(window,text="",bg="black",fg="white",font="none 19 bold")
l1.pack()
l1.focus_set()
l=Label(window,text="Enter headline of news:",bg="black",fg="white",font="none 12 bold")
l.pack()
l.focus_set()
e = Entry(window,width=200)
e.pack()
e.focus_set()
b = Button(window,text='submit',command=find_news)
b.pack(side='bottom')
window.mainloop()
我从一个函数中得到一个答案,根据它我必须在标签中设置它是否为假。如何为同一标签设置不同的值。 If is fake it comes FAKE one below another
答案 0 :(得分:0)
您要在主代码中创建标签,然后用config()
更新标签。就是说,我认为您没有做太多研究,因为这是tkinter的基本基础之一,并且已经有数百个或更多问题存在。
from tkinter import *
def find_news():
global e
string = e.get()
ans=infer.fake_fake(string)
if(ans==0):
w.config(text="FAKE", bg="red", fg="white", font="none 19 bold")
else:
w.config(text="REAL", bg="green", fg="white", font="none 19 bold")
window = Tk()
window.title('AVIS')
window.geometry("500x500")
window.configure(background='black')
l1 = Label(window, text="", bg="black", fg="white", font="none 19 bold")
l1.pack()
l = Label(window, text="Enter headline of news:", bg="black", fg="white", font="none 12 bold")
l.pack()
e = Entry(window,width=200)
e.pack()
w = Label(window, bg="black")
w.pack()
b = Button(window, text='submit', command=find_news)
b.pack(side='bottom')
window.mainloop()