python - Python 登录窗口
问题描述
我正在尝试以代码输入我的登录系统,一切正常。但是当我打开文件并且我的登录窗口出现时,我按X登录窗口关闭,您可以继续使用该程序。
我的问题是:当有人没有登录整个程序应该关闭而不仅仅是登录窗口时,我该怎么做?
谢谢你的帮助!
我的代码:
import secrets
from tkinter import *
from tkinter import messagebox
def Ok():
uname = e1.get()
password = e2.get()
if(uname == "" and password == "") :
messagebox.showinfo("", "Blank Not allowed")
elif(uname == "Admin" and password == "123"):
messagebox.showinfo("","Login Success")
root.destroy()
else :
messagebox.showinfo("","Incorrent Username and Password")
root = Tk()
root.title("Login")
root.geometry("300x200")
global e1
global e2
Label(root, text="UserName").place(x=10, y=10)
Label(root, text="Password").place(x=10, y=40)
e1 = Entry(root)
e1.place(x=140, y=10)
e2 = Entry(root)
e2.place(x=140, y=40)
e2.config(show="*")
Button(root, text="Login", command=Ok ,height = 3, width = 13).place(x=10, y=100)
root.mainloop()
pw = ""
zeichen = "QWERTZUIOPASDFGHJKLYXCVBNMqwertzuiopasdfghjklyxcvbnm123456789"
laenge = int(input("Bitte gib deine Passwortlänge ein: "))
for _ in range(laenge):
pw = pw+secrets.choice(zeichen)
print(pw)
解决方案
推荐阅读
- javascript - 未找到模块:无法解析“child_process”NextJS + Nightmare
- c++ - C++ GetAsyncKeyState 并不总是使用任何其他方法来获得鼠标点击?
- winforms - Winforms app packaged for MS Store displays incorrect icon on Taskbar
- java - Markdown 代码块中更漂亮的 java 格式
- ios - 如何在 iOS WebRTC 上启用 VP8?
- flutter - 键盘将 modalBottomSheet 推出边界,resizeToAvoidBottomInset 不起作用
- python - 如果成员数量少于 2,则使用不和谐机器人断开通话
- ruby - sinatra 中的小马邮件
- javascript - TypeError [ERR_INVALID_ARG_TYPE]:“数据”参数必须是字符串类型或 Buffer、TypedArray 或 DataView 的实例。收到未定义
- javascript - 如何在Javascript中提取嵌套对象中的复杂元素