PyQt5
PyQt5
[toc]
# Basic
- Python适配
虽然PyQt4可用于Python 2以及Python 3,但PyQt5只能与Python 3. *一起使用
# QDockWidget
self.layout = QtWidgets.QBoxLayout(2)
self.layout.addWidget(self.widget_one)
self.layout.addWidget(self.widget_two)
self.docked = QtWidgets.QDockWidget()
self.dockedWidget = QtWidgets.QWidget()
self.docked.setWidget(self.dockedWidget)
self.dockedWidget.setLayout(self.layout)
self.docked.show()
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
class DockDemo(QMainWindow):
def __init__(self, parent=None):
super(DockDemo, self).__init__(parent)
self.setCentralWidget(QTextEdit())
self.docked = QDockWidget("Dockable", self)
self.addDockWidget(Qt.LeftDockWidgetArea, self.docked)
self.dockedWidget = QWidget(self)
self.docked.setWidget(self.dockedWidget)
self.setWindowTitle("Dock demo")
self.dockedWidget.setLayout(QVBoxLayout())
for i in range(5):
self.dockedWidget.layout().addWidget(QPushButton("{}".format(i)))
if __name__ == '__main__':
import sys
app = QApplication(sys.argv)
ex = DockDemo()
ex.show()
sys.exit(app.exec_())
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
上次更新: 2023/10/10, 14:48:21