第一节按钮控件,文本控件,输入框,app图标
import sys
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton
if __name__ == '__main__':
app = QApplication(sys.argv)
w = QWidget()
w.setWindowTitle("第一个Pyqt")
# 添加按钮控件
btn = QPushButton("按钮")
# 在w窗口显示,添加到窗口
# btn = QPushButton("注册",w)
btn.setParent(w)
w.show()
app.exec_()
import sys
from PyQt5.QtWidgets import QApplication, QWidget, QLabel
if __name__ == '__main__':
app = QApplication(sys.argv)
w = QWidget()
w.setWindowTitle("第一个Pyqt")
# 下面创建了lable(纯文本),然后调用方法指明父类
lable = QLabel("账号", w)
# 显示位置于大小(x,y,w,h)
lable.setGeometry(20, 20, 30, 30)
w.show()
app.exec_()
?
import sys
from PyQt5.QtWidgets import QApplication, \
QWidget, QLabel, QLineEdit, QPushButton
if __name__ == '__main__':
app = QApplication(sys.argv)
w = QWidget()
w.setWindowTitle("第一个Pyqt")
# 下面创建了lable(纯文本),然后调用方法指明父类
lable = QLabel("账号:", w)
# 显示位置于大小(x,y,w,h)
lable.setGeometry(20, 20, 30, 30)
edit = QLineEdit(w)
edit.setPlaceholderText("请输入账号")
edit.setGeometry(55, 20, 200, 30)
# 添加按钮控件
btn = QPushButton("注册", w)
btn.setGeometry(50, 80, 70, 30)
w.resize(300, 300)
w.show()
app.exec_()
import sys
from PyQt5.QtWidgets import QApplication, \
QWidget, QLabel, QLineEdit, QPushButton, QDesktopWidget
if __name__ == '__main__':
app = QApplication(sys.argv)
w = QWidget()
w.setWindowTitle("第一个Pyqt")
# 下面创建了lable(纯文本),然后调用方法指明父类
lable = QLabel("账号:", w)
# 显示位置于大小(x,y,w,h)
lable.setGeometry(20, 20, 30, 30)
edit = QLineEdit(w)
edit.setPlaceholderText("请输入账号")
edit.setGeometry(55, 20, 200, 30)
# 添加按钮控件
btn = QPushButton("注册", w)
btn.setGeometry(50, 80, 70, 30)
width = 300
height = 300
w.resize(width, height)
# w.move(0, 0)
# 让窗口显示在屏幕中央
center_pointer = QDesktopWidget().availableGeometry().center()
x = center_pointer.x()
y = center_pointer.y()
w.move(x - width / 2, y - height / 2)
w.show()
app.exec_()
import sys
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QApplication, QWidget
if __name__ == '__main__':
app = QApplication(sys.argv)
w = QWidget()
w.setWindowTitle("看我的图标帅吗")
w.setWindowIcon(QIcon('D://Jupyter//GUI//icon//app图片.png'))
w.show()
app.exec_()
快速入门第一节