📜  在 pyqt 中创建按钮 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:17.891000             🧑  作者: Mango

代码示例1
# needs to be imported first from from PyQt5.QtWidgets
from PyQt5.QtWidgets import QPushButton
btn = QPushButton("button1") # create it

# now you can add it to your layout
layout = QHBoxLayout() # from PyQt5.QtWidgets import QHBoxLayout
layout.addWidget(btn)
# or you can just add it to the window itself like:
btn = QPushButton("button1", self)