How do I create an automatically updating GUI using Tkinter?

后端 未结 5 1762
梦如初夏
梦如初夏 2020-11-30 10:40
from Tkinter import *
import time
#Tkinter stuff

class App(object):
    def __init__(self):
        self.root = Tk()

        self.labeltitle = Label(root, text=\"\         


        
5条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-30 11:12

    I wrote an example with Python 3.7

    from tkinter import *
    
    def firstFrame(window):
        global first_frame
        first_frame = Frame(window)
        first_frame.place(in_=window, anchor="c", relx=.5, rely=.5)
        Label(first_frame, text="ATTENTION !").grid(row=1,column=1,columnspan=3)
    
    
    def secondFrame(window):
        global second_frame
        second_frame= Frame(window, highlightbackground=color_green, highlightcolor=color_green, highlightthickness=3)
        second_frame.place(in_=window, anchor="c", relx=.5, rely=.5)
        Label(second_frame, text="This is second frame.").grid(row=1, column=1, columnspan=3, padx=25, pady=(15, 0))
    
    
    window = Tk()
    window.title('Some Title')
    window.attributes("-fullscreen", False)
    window.resizable(width=True, height=True)
    window.geometry('300x200')
    
    
    firstFrame(window)
    secondFrame(window)
    first_frame.tkraise()
    window.after(5000, lambda: first_frame.destroy()) # you can try different things here
    window.mainloop()
    

提交回复
热议问题