create button in pyqt

Solutions on MaxInterview for create button in pyqt by the best coders in the world

showing results for - "create button in pyqt"
Bryn
31 Jul 2016
1# needs to be imported first from from PyQt5.QtWidgets
2from PyQt5.QtWidgets import QPushButton
3btn = QPushButton("button1") # create it
4
5# now you can add it to your layout
6layout = QHBoxLayout() # from PyQt5.QtWidgets import QHBoxLayout
7layout.addWidget(btn)
8# or you can just add it to the window itself like:
9btn = QPushButton("button1", self)