帮我设计一个UI界面,有账号输入框、密码输入框和保存、登录按钮。
时间: 2024-03-14 11:49:24 浏览: 14
好的,这是一个简单的登录界面,使用 Python 的 PyQt5 库来实现:
```python
from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QLineEdit, QPushButton, QVBoxLayout, QHBoxLayout
class Login(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle('登录')
self.resize(300, 150)
self.initUI()
def initUI(self):
# 创建控件
self.account_label = QLabel('账号')
self.account_edit = QLineEdit()
self.password_label = QLabel('密码')
self.password_edit = QLineEdit()
self.password_edit.setEchoMode(QLineEdit.Password) # 设置密码输入框为密码模式
self.save_button = QPushButton('保存')
self.login_button = QPushButton('登录')
# 添加控件
vbox1 = QVBoxLayout()
vbox1.addWidget(self.account_label)
vbox1.addWidget(self.password_label)
vbox2 = QVBoxLayout()
vbox2.addWidget(self.account_edit)
vbox2.addWidget(self.password_edit)
hbox = QHBoxLayout()
hbox.addLayout(vbox1)
hbox.addLayout(vbox2)
hbox_button = QHBoxLayout()
hbox_button.addWidget(self.save_button)
hbox_button.addWidget(self.login_button)
vbox_main = QVBoxLayout()
vbox_main.addLayout(hbox)
vbox_main.addLayout(hbox_button)
self.setLayout(vbox_main)
if __name__ == '__main__':
import sys
app = QApplication(sys.argv)
login = Login()
login.show()
sys.exit(app.exec_())
```
这个界面包含了账号输入框、密码输入框和保存、登录按钮。其中,密码输入框为密码模式,输入的字符会被隐藏。