
用 python tkinter 写了个 Windows 桌面程序, 想做个登录界面,用户登录通过以后再跳转到主界面。找了很久终于找到一个能达到目的的方法,但是不知道这个方法是否存在安全隐患,也就是说用户能轻松跳过验证直接显示主界面。顺便说一下这个程序会编译成 exe 。以下是原理:
import tkinter as tk root = tk.Tk() root.geometry('500x300') #In order to hide main window root.withdraw() tk.Label(root, text="Main Window").pack() aWindow = tk.Toplevel(root) aWindow.geometry('200x100') def change_window(): #remove the other window entirely aWindow.destroy() #make root visible again root.iconify() root.deiconify() username = tk.StringVar() tk.Entry(aWindow, textvariable=username).pack() tk.Button(aWindow, text="Login", command=change_window).pack() root.mainloop() 欢迎大佬们指点,多谢!
1 no1xsyzy 2020-06-04 09:57:09 +08:00 Python 一般没有真 exe |
2 chengxiao 2020-06-04 10:29:01 +08:00 真的要用 Python 写 GUI 的话,还是去看下 PyQT 吧 tk 折腾过一段时间发现实在是太难用了 |
4 XIVN1987 2020-06-04 15:49:59 +08:00 Tk 的界面这么丑,我不明白 Python 为啥一定要带着它 真觉得 GUI 必须,,换个好看点儿的不行吗??哪怕功能简陋些也许啊 |
5 panzhangwang 2020-06-05 09:02:22 +08:00 |
6 ungrown 2020-10-15 10:09:42 +08:00 |