首页 > 解决方案 > Tkinter 帧删除

问题描述

好吧,这是我的问题。我目前正在为 discord.js 机器人制作 GUI(我知道如何在 python 和 node 之间进行交互),但我的问题是我有一个“密码”4 位密码,应该发生的是:

每当您输入四位数字密码时,它都应该删除框架、条目、文本等(Unpack/destroy()),但它并没有这样做。但是,它是删除文本和文本入口点,而不是实际框架本身。

>##Importing Functions (eg, npm modules but in python)
from tkinter import *
from tkinter import ttk
from random import randint
import sys
##Root core
root = Tk()

##Developers pin-codes

JaredP = "9119"


##End

##Hash Check + Main core functions
def check_pin():
    if code.get() == JaredP:

        ##Main Core (After auth is done forget packs at bottom)




        #End of main


##End of check


##Frames for the main core function(Auth)

content = ttk.Frame(root, padding=(6,6,12,12))
frame = ttk.Frame(content, borderwidth=5, relief="sunken", width=200, height=100)
checkt = ttk.Label(content, text="Hello, please enter your 4 digit pin.", padding=(12,12,12,12))
namelbl = ttk.Label(content, text="Access Code")
code = ttk.Entry(content)
submit = ttk.Button(content, text="Submit", width=10, command=check_pin)


##End of frames

##Design##

root.title("TEX")
root.wm_iconbitmap('icon.ico')

##End##

##Packing for main body

content.pack()
checkt.pack()

namelbl.pack()
code.pack()
submit.pack()

root.mainloop()
##End of packing

标签: pythontkinter

解决方案


要删除您可以使用,YOUR_FRAME.pack_forget()或者YOUR_GRID.grid_forget()取决于框架是打包还是网格。

如果您不打算再次使用它(独立地,如果它是框架或网格)YOUR_ELEMENT.destroy()


推荐阅读