-
Notifications
You must be signed in to change notification settings - Fork 191
Expand file tree
/
Copy pathcustomizer_widgets.py
More file actions
31 lines (23 loc) · 1.31 KB
/
customizer_widgets.py
File metadata and controls
31 lines (23 loc) · 1.31 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
from .scad_variable import ScadVariable
class CustomizerDropdownVariable(ScadVariable):
def __init__(self, name, default_value, options='', label='', tab=''):
if isinstance(options, list):
options_str = '[' + ", ".join(map(str, options)) + ']'
if isinstance(options, dict):
reverse_options = [ f'{options[k]} : "{k}"' for k in options.keys()]
options_str = f'[{", ".join(reverse_options)}]'
super().__init__(name, default_value, options_str, label=label, tab=tab)
class CustomizerSliderVariable(ScadVariable):
def __init__(self, name, default_value, min_, max_, step='', label='', tab=''):
options_str = '['
options_str += min_ and str(min_) + ':'
options_str += step and str(step) + ':'
options_str += str(max_) + ']'
super().__init__(name, default_value, options_str, label=label, tab=tab)
class CustomizerCheckboxVariable(ScadVariable):
def __init__(self, name, default_value, label='', tab=''):
super().__init__(name, default_value, label=label, tab=tab)
class CustomizerTextboxVariable(ScadVariable):
def __init__(self, name, default_value, max_length='', label='', tab=''):
options_str = max_length and str(max_length)
super().__init__(name, default_value, options_str, label=label, tab=tab)