-
Notifications
You must be signed in to change notification settings - Fork 2
/
basics.py
49 lines (35 loc) · 1.44 KB
/
basics.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
from PySide2 import QtWidgets as qtw
from PySide2 import QtGui as qtg
# A simple Panel class with some basic widgets
class Panel(qtw.QWidget):
def __init__(self):
# call super
super(Panel, self).__init__()
self.label = qtw.QLabel('Username')
self.button = qtw.QPushButton('Start')
self.button.setIcon(qtg.QIcon('example_icon.png'))
self.button.setToolTip('shortcut: u')
self.button.setShortcut('u')
self.checkbox = qtw.QCheckBox('agree to GDPR')
self.checkbox.setChecked(True)
# A QCompleter helps users by giving autocompletion
self.user_line = qtw.QLineEdit()
self.users = ['harry', 'hermione', 'ron', 'hagrid']
self.completer_line = qtw.QCompleter(self.users)
self.user_line.setCompleter(self.completer_line)
self.user_line.setPlaceholderText('enter you name here..')
self.combobox = qtw.QComboBox()
self.permissions_combobox = ['r', 'w', 'rx', 'rw', 'rwx']
self.combobox.addItems(self.permissions_combobox)
self.vlayout = qtw.QVBoxLayout()
self.vlayout.addWidget(self.label)
self.vlayout.addWidget(self.user_line)
self.vlayout.addWidget(self.checkbox)
self.vlayout.addWidget(self.combobox)
self.vlayout.addSpacing(25)
self.vlayout.addWidget(self.button)
self.setLayout(self.vlayout)
app = qtw.QApplication()
panel = Panel()
panel.show()
app.exec_()