python - 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
解决方案
要删除您可以使用,YOUR_FRAME.pack_forget()
或者YOUR_GRID.grid_forget()
取决于框架是打包还是网格。
如果您不打算再次使用它(独立地,如果它是框架或网格)YOUR_ELEMENT.destroy()
推荐阅读
- python - 使用 scipy 从 delaunay 三角剖分输出顶点
- javascript - 将变量从调用的 Lambda 函数传递到 DynamoDB
- vue.js - 如何在 vue 的详细信息页面上显示数据?
- react-native - 如何从函数启动 React-Native-Animatable 动画?
- excel - Excel 中带有总和的进度图标
- angular - 我想显示用户列表并通过图表显示他们各自的数据
- r - 时间序列数据的数据差距问题
- sql - postgres:计算每次行程的标准差值
- django - 如何在模型中创建 ForeignKey 字段,在管理视图中显示文本名称而不是 URL?
- delphi - TidTCPClient 与 TidTCPServer 保持连接状态多长时间没有包通信