-
Notifications
You must be signed in to change notification settings - Fork 2
/
qlistwidget.py
33 lines (24 loc) · 921 Bytes
/
qlistwidget.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
from PySide2 import QtWidgets as qtw
from PySide2 import QtGui as qtg
class Panel(qtw.QWidget):
def __init__(self):
super(Panel, self).__init__()
list_widget = qtw.QListWidget()
shots = ['004', '001', '003', '002', '005']
for i, shot in enumerate(shots):
item = qtw.QListWidgetItem(shot)
item.setToolTip('shot {}'.format(i))
item.setIcon(qtg.QIcon('shot.png'))
item.setBackgroundColor(qtg.QColor(152, 106, 232))
list_widget.addItem(item)
# we can sort stuff
list_widget.sortItems()
list_widget.setAlternatingRowColors(True)
list_widget.setSelectionMode(qtw.QAbstractItemView.ExtendedSelection)
master_layour = qtw.QVBoxLayout()
master_layour.addWidget(list_widget)
self.setLayout(master_layour)
app = qtw.QApplication()
panel = Panel()
panel.show()
app.exec_()