python - 之后如何将此条目答案导入文本
问题描述
好的,所以我有这个注册表单,有一部分你必须输入你的名字,我希望那个名字的答案被带到后面的页面。
import tkinter as tk
root = tk.Tk()
root.geometry("150x50+680+350")
def FormSubmission():
global button_start
button_start.place_forget()
l1.place_forget()
root.attributes("-fullscreen", True)
frame = tk.Frame(root)
tk.Label(frame, text="First Name:").grid(row=0)
name = entry1 = tk.Entry(frame) # I want the name written here to be taken from here to the welcome text.
entry1.grid(row=0, column=1)
tk.Label(frame, text="Last Name:").grid(row=1)
e2 = tk.Entry(frame)
e2.grid(row=1, column=1)
tk.Label(frame, text="Email:").grid(row=2)
e3 = tk.Entry(frame)
e3.grid(row=2, column=1)
tk.Label(frame, text="Date of Birth:").grid(row=3)
e4 = tk.Entry(frame)
e4.grid(row=3, column=1)
frame.pack(anchor='center', expand=True)
button_next = tk.Button(frame, text = "Next", height = 2, width = 7, command =lambda: MainPage(frame))
button_next.grid(row=4, column=1)
def MainPage(frame):
global FormSubmission
frame.pack_forget()
root.attributes("-fullscreen", True)
l1.place(x = 500, y = 10)
button_start.place_forget()
l1 = tk.Label(root, text="Welcome," , font=("Arial", 44)) #As you can see here in this line I want the entry 1 name here after welcome and the comma
button_start = tk.Button(root, text="Start", height=3, width=20, command = FormSubmission)
button_start.place(x = 0, y = 10)
button_exit = tk.Button(root, text="Exit", command=root.destroy)
button_exit.place(x=1506, y=0)
root.mainloop()
我想要做的是获取条目 1 的答案并将其放入欢迎文本中。我所说的线上有一个指标。
解决方案
这是一个如何从您的小部件条目中提供文本的示例1
在函数 FormSubmission() 中:定义按钮的地方应该传递要在标签中显示的文本
button_next = tk.Button(frame, text = "Next", height = 2, width = 7, command =lambda: MainPage(frame, entry1.get()))
在函数 MainPage(frame): 你应该为你的标签设置文本:
def MainPage(frame, entry1): global FormSubmission frame.pack_forget() root.attributes("-fullscreen", True) l1.place(x = 500, y = 10) button_start.place_forget() l1.config(text="Welcome," + entry1) #<-------
推荐阅读
- oauth - 使用 JWT 保护后端微服务之间的通信
- javascript - 在启动时删除带有 javascript 失败的 div
- javascript - 两个DIV的同步位置
- react-native - React Native 链接/图标样式
- php - 实现 PHP 会话令牌时的问题
- python - Python 3.6 将日志信息保存在缓冲区中,然后发送
- asp.net - SignalR/Angular:无法加载“url”。对预检请求的响应未通过访问控制检查。
- gradle - Gradle:使用依赖 jar 中的资源作为源集
- c# - 从 XML 生成的 dataset-parent-child-tables C# 更新 SQL Server -with-autogenerated-identity-key
- r - 将多个弹出窗口添加到单个标记位置坐标