-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
126 lines (113 loc) · 3.98 KB
/
test.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/usr/bin/env python3
import os
import sys
from qui.ui.widget import ToolWidget
from qui.settings import (
backend,
Setting,
SettingsHandler,
ToolSettings,
)
import unreal_stylesheet
from PySide6.QtWidgets import *
class MehToolSettings(ToolSettings):
def __init__(self, scope):
super().__init__(scope)
self.backends.update({
'prj': backend.JSONReadOnlySettings(
os.path.join(
os.environ.get("TEST_PROJECT_PATH", "."),
"Config", "Pipeline", "pipeline.json"
)
),
'usr': backend.JSONReadWriteSettings(
os.path.join(".", "usr_settings.json")
),
})
# def __getattr__(self, item):
# if hasattr(self.backends[self.scope], item) is True:
# return getattr(self.backends[self.scope], item)
# raise AttributeError(
# "Scope {} has no attribute {}".format(repr(self.scope), repr(item))
# )
class MehToolWidget(ToolWidget):
def __init__(self):
super().__init__()
self.doc_url = "https://fett263.com"
self.settings = SettingsHandler(
self,
save_slot=self.save_settings_slot,
load_slot=self.load_settings_slot,
)
settings = [
Setting(
'my_boolean', 'boolean', 'usr',
label="My Boolean",
default_value=False,
tooltip= "MY BOOLEAN EXAMPLE",
),
Setting(
'my_combo_box', 'combo_box', 'usr',
label="My Combo Box",
default_value=0, # index
tooltip="MY COMBO BOX EXAMPLE",
),
Setting(
'my_filename', 'filename', 'usr',
label="My Filename",
tooltip="MY FILENAME EXAMPLE",
default_value="DEFAULT MY FILENAME VALUE",
),
Setting(
'my_integer', 'integer', 'usr',
label="My Integer",
default_value=0,
tooltip= "The button color when the button is disabled.",
),
Setting(
'my_rgb_color', 'rgb_color', 'usr',
label="My RGB Color",
default_value='Gray',
tooltip= "MY RGB COLOR EXAMPLE",
),
Setting(
'my_string_line_array', 'string_line_array', 'lcl',
label="My String Line Array",
default_value=["DEFAULT STRING LINE ARRAY VALUE", "AND ANOTHER LINE"],
tooltip=(
"MY STRING ARRAY EXAMPLE\n"
"(One directory per line)"
)
),
]
[self.settings + s for s in settings]
self.setLayout(QVBoxLayout())
self.layout().addWidget(QLabel("My Awesome Tool !!!!"))
def load_settings_slot(self):
"""
Default implementation to set the initial's values to self.items.
"""
# raise NotImplementedError
# Example:
scoped_dict = self.settings.scoped_dict()
usr_settings = MehToolSettings('usr').get(self.settings.domain, {})
scoped_dict.get('usr', {}).update(usr_settings)
for i in self.settings:
if 'usr' in i.scopes:
i.setValue(scoped_dict.get('usr', {}).get(i.name, i.default_value))
def save_settings_slot(self, settings_update=None):
raise NotImplementedError
# Example:
# settings = TestAppSettings('usr').get(self.settings.domain, {})
# settings.update(settings_update)
# TestAppSettings('usr').set(self.settings.domain, settings)
def main(argv):
app = QApplication(argv)
# unreal_stylesheet.setup(app)
tool_widget = MehToolWidget()
tool_widget.setWindowTitle("Test Using QUi package")
tool_widget.resize(640, 480)
tool_widget.show()
return app.exec()
if __name__ == "__main__":
sys.exit(main(sys.argv))