Repository navigation
Expand file tree
/
Copy pathControlToolBox.py
More file actions
74 lines (56 loc) · 1.75 KB
/
Copy pathControlToolBox.py
File metadata and controls
74 lines (56 loc) · 1.75 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/python
# -*- coding: utf-8 -*-
from pyforms.utils.settings_manager import conf
from AnyQt import _api
from AnyQt.QtWidgets import QToolBox
from AnyQt.QtWidgets import QFrame
from AnyQt.QtWidgets import QVBoxLayout
from AnyQt.QtWidgets import QHBoxLayout
from pyforms.gui.controls.ControlBase import ControlBase
class ControlToolBox(ControlBase):
def init_form(self):
self._form = QToolBox()
# self.form.layout().setMargin(0)
@property
def value(self):
return self._value
@value.setter
def value(self, value):
ControlBase.label.fset(self, value);
for item in range(self.form.count(), -1, -1): self.form.removeItem(item)
for item in value:
if isinstance(item, tuple):
widget = QFrame(self.form);
layout = QVBoxLayout();
if _api.USED_API == _api.QT_API_PYQT5:
layout.setContentsMargins(0,0,0,0)
elif _api.USED_API == _api.QT_API_PYQT4:
layout.setMargin(0)
widget.setLayout(layout)
for e in item[1]:
if isinstance(e, tuple):
hwidget = QFrame(self.form);
hlayout = QHBoxLayout();
if _api.USED_API == _api.QT_API_PYQT5:
hlayout.setContentsMargins(0,0,0,0)
elif _api.USED_API == _api.QT_API_PYQT4:
hlayout.setMargin(0)
hwidget.setLayout(hlayout)
for ee in e:
hlayout.addWidget(ee.form)
widget.layout().addWidget(hwidget)
else:
widget.layout().addWidget(e.form)
self.form.addItem(widget, item[0])
else:
self.form.addItem(item.form, item.label)
def set_item_enabled(self, index, enabled):
"""
Enable or disable an item
"""
self.form.setItemEnabled(index, enabled)
def is_item_enabled(self, index):
"""
Check if an item is enabled or disabled
"""
return self.form.isItemEnabled(index)