QT
一、最小系统
from PyQt5.QtWidgets importQApplication,QWidget
import sys
app=QApplication(sys.argv)
window=QWidget()
window.setGeometry(200,100,800,600)
window.setWindowTitle('第一个窗口')
window.show()
sys.exit(app.exec_())
二、常用控件
import sys
from PyQt5.QtWidgets import QApplication, QWidget
from PyQt5.QtWidgets import QLabel, QPushButton, QRadioButton, QCheckBox, QCommandLinkButton, QDialogButtonBox
from PyQt5.QtWidgets import QLineEdit, QTextEdit, QPlainTextEdit, QSpinBox, QDoubleSpinBox, QComboBox, QFontComboBox
from PyQt5.QtWidgets import QTimeEdit, QDateEdit, QDateTimeEdit, QDial, QSlider
from PyQt5.Qt import Qt
from datetime import date
class MainWindow(QWidget):
def __init__(sele):
super(MainWindow,sele).__init__()
self.create_ui()
self.setGeometry(100,100,800,600)
self.setWindowTitle('常用控件')
self.show()
def create_ui(self):
label=QLabel('用户名',self)
label.move(50,10)
btn1=QPushButton('确定',self)
btn1.move(50,50)
btn2=QRadioButton('男',self)
btn2.move(50,100)
btn3=QCheckBox('篮球',self)
btn3.move(50,150)
btn4=QCommandLinkButton('hello', 'hello world', self)
btn4.move(50,200)
b1=QDialogButtonBox.StandarButton.ok
b2 = QDialogButtonBox.StandardButton.Cancel
b3 = QDialogButtonBox.StandardButton.Yes