python用户登录界面设计
时间: 2023-07-26 09:49:16 浏览: 47
好的,以下是一个简单的Python用户登录界面设计示例:
```python
from tkinter import *
# 创建窗口
root = Tk()
# 设置窗口标题
root.title("用户登录")
# 设置窗口大小
root.geometry("300x200")
# 设置标签和输入框
Label(root, text="用户名:").place(x=50, y=30)
Label(root, text="密码:").place(x=50, y=70)
Entry(root).place(x=110, y=30)
Entry(root, show="*").place(x=110, y=70)
# 定义登录函数
def login():
# 获取用户名和密码
username = Entry(root).get()
password = Entry(root, show="*").get()
# 校验用户名和密码
if username == "admin" and password == "123":
print("登录成功!")
else:
print("用户名或密码错误!")
# 设置登录按钮
Button(root, text="登录", command=login).place(x=130, y=120)
# 进入消息循环
root.mainloop()
```
这个示例使用了Python的GUI库Tkinter,创建了一个用户登录窗口,包括用户名和密码输入框以及登录按钮。当用户点击登录按钮时,会调用登录函数进行用户名和密码的校验。如果用户名和密码正确,会输出登录成功的提示;否则会输出用户名或密码错误的提示。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)