展开全部
你好,你将2113两个root和root1共用一个mainloop了。所5261以frame1的那个显示出问题了4102,下面是我修改以后的代1653码。from tkinter import *
def create():
var.set("++早上好!")
root1 = Tk()
frame0 = Frame(root1)
filename = r"C:\Users\nxf36039\Desktop\20190116115007169.gif"
photo = PhotoImage(file = filename)
var1 = StringVar()
var1.set("早上好!")
#theLabel = Label(root1, text = '学java开发\n到开源社区', justify=LEFT, image=photo, compound=CENTER, font=('黑体',20), fg="blue" )
theLabel = Label(root1, textvariable =var1, justify=LEFT, image=photo, compound=CENTER, font=('黑体',20), fg="blue" )
theLabel.pack()
mainloop()
def callback():
var.set("早上好!")
def main():
root = Tk()
root.title("LIN")
root.geometry("400x450")
frame1 = Frame(root)
frame1.place(x=100, y=10)
frame2 = Frame(root)
var = StringVar()
var.set("小主,早上好!")
textLabel = Label(frame1,textvariable=var,justify=LEFT)
#textLabel = Label(frame1,text="nihao")
textLabel.pack()
theButton1 = Button(frame1,text="回复",command=callback)
#theButton1.grid(padx=20,pady=20)
theButton2 = Button(frame2,text="退出",bg="black",fg="white",command=root.destroy)
theButton2.grid(padx=40,pady=40)
frame1.pack(padx=20,pady=20)
frame2.pack(padx=60,pady=150)
mainloop()
if __name__ == '__main__':
main()