-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_docking.py
59 lines (50 loc) · 1.79 KB
/
test_docking.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from PyQt5.QtWidgets import QMainWindow, QApplication, QDockWidget, QListWidget, QTextEdit
import sys
from PyQt5.QtGui import QIcon
from PyQt5 import QtGui
from PyQt5.QtCore import Qt
class DockDialog(QMainWindow):
def __init__(self):
super().__init__()
self.title = "PyQt5 StackedWidget"
self.top = 200
self.left = 500
self.width = 400
self.height = 300
self.setWindowIcon(QtGui.QIcon("icon.png"))
self.setWindowTitle(self.title)
self.setGeometry(self.left, self.top, self.width, self.height)
self.createDockWidget()
self.createDockWidget2()
self.show()
def createDockWidget(self):
menubar = self.menuBar()
file = menubar.addMenu("File")
file.addAction("New")
file.addAction("Save")
file.addAction("Close")
self.dock = QDockWidget("Dockable", self)
self.listWiget = QListWidget()
list = ["Python", "C++", "Java", "C#"]
self.listWiget.addItems(list)
self.dock.setWidget(self.listWiget)
self.dock.setFloating(False)
self.setCentralWidget(QTextEdit())
self.addDockWidget(Qt.TopDockWidgetArea, self.dock)
def createDockWidget2(self):
menubar = self.menuBar()
file = menubar.addMenu("File")
file.addAction("New")
file.addAction("Save")
file.addAction("Close")
self.dock = QDockWidget("Dockable", self)
self.listWiget = QListWidget()
list = ["A"]
self.listWiget.addItems(list)
self.dock.setWidget(self.listWiget)
self.dock.setFloating(False)
self.setCentralWidget(QTextEdit())
self.addDockWidget(Qt.TopDockWidgetArea, self.dock)
App = QApplication(sys.argv)
window = DockDialog()
sys.exit(App.exec())