是一种查找帧信息以保存接口数据的方法吗?

2024-10-02 02:35:05 发布

您现在位置:Python中文网/ 问答频道 /正文

接口的示例代码:

from tkinter import *

root = Tk()

class logic:
    def qui_add_on_screen(root):
        def make_line(root):
            frmH = Frame(root)
            frmH.pack(expand=True, fill="x", side="top")
            Button(frmH, text="Add content", bg="lightgreen", command=lambda: logic.gui_content(frmH)
                   ).pack(fill="both", side="right")

        frmV = Frame(root)
        frmV.pack(expand=True, fill="x", side="top")
        Button(frmV, text="Add line", bg="lightblue", command=lambda: make_line(frmV)
               ).pack(fill="both", side="bottom")

    def gui_content(root):
        frm_main = Frame(root)
        frm_main.pack(fill="x", side="left")

        e = Entry(frm_main)
        e.insert(0, "Some content here...")
        e.pack(fill="x", side="top")
        Button(frm_main, text="Delete content!", bg="tomato", command=lambda: frm_main.destroy()
               ).pack(fill="x", side="bottom")

class example:
    def __init__(self, master):
        self.master = master
        x = 600
        y = 300
        master.geometry(f"{x}x{y}+{(master.winfo_screenwidth() - x) // 2}+{(master.winfo_screenheight() - y) // 2}")
        master.title("Example GUI")

        logic.qui_add_on_screen(master)

if __name__ == "__main__":
    example(root)
    root.mainloop()

这将允许用户在屏幕上存储多少内容,但我的问题是我不知道如何跟踪它。我想跟踪它,因为我想建立一个保存系统,在应用程序关闭时保存屏幕上的所有更改,并在重新打开时返回。 我本想跟踪帧信息,但我得到的只是.!frame.!frame.!frame,并不是很有帮助。关于如何从屏幕上保存/跟踪内容框架,以便在下次应用程序使用时将其返回,您有什么想法吗


Tags: mastermaintopdeflinerootcontentfill

热门问题