用pycharm写用户登录界面代码
时间: 2023-06-03 12:03:21 浏览: 508
好的,我可以回答这个问题。您可以使用Python的Tkinter库来创建登录界面。以下是一个简单的代码示例:
```python
from tkinter import *
def login():
username = entry_username.get()
password = entry_password.get()
if username == "admin" and password == "123456":
label_result.config(text="登录成功")
else:
label_result.config(text="用户名或密码错误")
root = Tk()
root.title("用户登录")
root.geometry("300x200")
label_username = Label(root, text="用户名:")
label_username.grid(row=0, column=0)
entry_username = Entry(root)
entry_username.grid(row=0, column=1)
label_password = Label(root, text="密码:")
label_password.grid(row=1, column=0)
entry_password = Entry(root, show="*")
entry_password.grid(row=1, column=1)
button_login = Button(root, text="登录", command=login)
button_login.grid(row=2, column=0)
label_result = Label(root, text="")
label_result.grid(row=2, column=1)
root.mainloop()
```
您可以将此代码复制并粘贴到PyCharm中,并运行它以查看结果。
相关推荐
![](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)
![](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)