@@ -11,6 +11,7 @@ class ControlForm(QWidget):
11
11
def __init__ (self , parent = None , control_attributes = None ):
12
12
super ().__init__ (parent )
13
13
self .control_attributes = control_attributes
14
+ self .update_modified_state = None
14
15
15
16
# Layout for the control-specific attributes
16
17
self .layout = QVBoxLayout (self )
@@ -53,24 +54,24 @@ def create_pushbutton_attributes(self, properties):
53
54
self .create_default_textures (properties )
54
55
55
56
def create_radiobutton_attributes (self , properties ):
56
- self .create_attributes_for_control (properties . attributes ['RADIOBUTTONDATA' ][0 ])
57
+ self .create_attributes_for_control (properties [ ' attributes' ] ['RADIOBUTTONDATA' ][0 ])
57
58
self .create_default_textures (properties )
58
59
59
60
def create_entryfield_attributes (self , properties ):
60
- entryfield_data = normalize_boolean_values (properties . attributes [ 'ENTRYFIELDDATA ' ],
61
+ entryfield_data = normalize_boolean_values (properties [ ' attributes' ][ 'TEXTENTRYDATA ' ],
61
62
['SECRETTEXT' , 'NUMERICALONLY' , 'ALPHANUMERICALONLY' , 'ASCIIONLY' ])
62
63
self .create_attributes_for_control (entryfield_data )
63
64
self .create_default_textures (properties )
64
65
65
66
def create_statictext_attributes (self , properties ):
66
- self .create_attributes_for_control (properties . attributes ['STATICTEXTDATA' ][0 ])
67
+ self .create_attributes_for_control (properties [ ' attributes' ] ['STATICTEXTDATA' ][0 ])
67
68
self .create_default_textures (properties )
68
69
69
70
def create_progressbar_attributes (self , properties ):
70
71
self .create_default_textures (properties )
71
72
72
73
def create_scrolllistbox_attributes (self , properties ):
73
- listbox_data = normalize_boolean_values (properties . attributes ['LISTBOXDATA' ],
74
+ listbox_data = normalize_boolean_values (properties [ ' attributes' ] ['LISTBOXDATA' ],
74
75
['AUTOSCROLL' , 'AUTOPURGE' , 'SCROLLBAR' , 'MULTISELECT' , 'FORCESELECT' ])
75
76
76
77
self .create_attributes_for_control (listbox_data )
@@ -85,7 +86,7 @@ def create_scrolllistbox_attributes(self, properties):
85
86
self .create_textures_for_control (textures )
86
87
87
88
def create_combobox_attributes (self , properties ):
88
- combobox_data = normalize_boolean_values (properties . attributes ['COMBOBOXDATA' ],
89
+ combobox_data = normalize_boolean_values (properties [ ' attributes' ] ['COMBOBOXDATA' ],
89
90
['ISEDITABLE' , 'ASCIIONLY' , 'LETTERSANDNUMBERS' ])
90
91
self .create_attributes_for_control (combobox_data )
91
92
@@ -100,24 +101,24 @@ def create_combobox_attributes(self, properties):
100
101
'SLIDERTHUMBENABLEDDRAWDATA' , 'SLIDERTHUMBDISABLEDDRAWDATA' , 'SLIDERTHUMBHILITEDRAWDATA'
101
102
]
102
103
103
- textures = {key : filter_empty_properties (properties . textures [key ]) for key in texture_keys }
104
+ textures = {key : filter_empty_properties (properties [ ' textures' ] [key ]) for key in texture_keys }
104
105
self .create_textures_for_control (textures )
105
106
106
107
def create_checkbox_attributes (self , properties ):
107
108
self .create_default_textures (properties )
108
109
109
110
def create_slider_attributes (self , properties ):
110
- slider_data = normalize_boolean_values (properties . attributes ['SLIDERDATA' ], [])
111
+ slider_data = normalize_boolean_values (properties [ ' attributes' ] ['SLIDERDATA' ], [])
111
112
self .create_attributes_for_control (slider_data )
112
113
texture_keys = ['ENABLEDDRAWDATA' , 'DISABLEDDRAWDATA' , 'HILITEDRAWDATA' , 'SLIDERTHUMBENABLEDDRAWDATA' ,
113
114
'SLIDERTHUMBDISABLEDDRAWDATA' , 'SLIDERTHUMBHILITEDRAWDATA' ]
114
- textures = {key : filter_empty_properties (properties . textures [key ]) for key in texture_keys }
115
+ textures = {key : filter_empty_properties (properties [ ' textures' ] [key ]) for key in texture_keys }
115
116
self .create_textures_for_control (textures )
116
117
117
118
118
119
def create_default_textures (self , properties ):
119
120
texture_keys = ['ENABLEDDRAWDATA' , 'DISABLEDDRAWDATA' , 'HILITEDRAWDATA' ]
120
- textures = {key : filter_empty_properties (properties . textures [key ]) for key in texture_keys }
121
+ textures = {key : filter_empty_properties (properties [ ' textures' ] [key ]) for key in texture_keys }
121
122
self .create_textures_for_control (textures )
122
123
123
124
def create_attributes_for_control (self , attributes ):
@@ -170,7 +171,7 @@ def update_texture_color(texture_type, image, color_picker_app):
170
171
color = color_picker_app .color_data ['texture_layout' ]['color' ]
171
172
border = color_picker_app .color_data ['texture_layout' ]['shadow' ]
172
173
173
- self .update_texture_property (texture_type , 'color ' , image , (
174
+ self .update_texture_property (texture_type , 'COLOR ' , image , (
174
175
color .red (), color .green (), color .blue (), color .alpha ()))
175
176
self .update_texture_property (texture_type , 'BORDERCOLOR' , image , (
176
177
border .red (), border .green (), border .blue (), border .alpha ()))
@@ -181,14 +182,14 @@ def update_texture_color(texture_type, image, color_picker_app):
181
182
section = CollapsibleSection (title = texture_type_name , parent = self ,
182
183
section_manager = outer_section_manager )
183
184
for texture in texture_data :
184
- inner_section_title = texture .get ('image ' , 'No Image' )
185
+ inner_section_title = texture .get ('IMAGE ' , 'No Image' )
185
186
inner_section = create_inner_section (inner_section_title , section , inner_section_manager ,
186
187
"InnerSection" )
187
188
188
189
color_picker_app = ColorPickerApp (
189
190
color_data = {'texture_layout' : {
190
- "color" : QColor (texture .get ('color ' )[0 ], texture .get ('color ' )[1 ], texture .get ('color ' )[2 ],
191
- texture .get ('color ' )[3 ]),
191
+ "color" : QColor (texture .get ('COLOR ' )[0 ], texture .get ('COLOR ' )[1 ], texture .get ('COLOR ' )[2 ],
192
+ texture .get ('COLOR ' )[3 ]),
192
193
"shadow" : QColor (texture .get ('BORDERCOLOR' )[0 ], texture .get ('BORDERCOLOR' )[1 ],
193
194
texture .get ('BORDERCOLOR' )[2 ], texture .get ('BORDERCOLOR' )[3 ])
194
195
}}
@@ -210,25 +211,28 @@ def update_texture_color(texture_type, image, color_picker_app):
210
211
self .layout .addWidget (section )
211
212
212
213
def update_sub_property (self , main_key , sub_key , value = None ):
213
- list_dict = self .control_attributes . textures \
214
- if main_key in self .control_attributes . textures \
215
- else self .control_attributes . attributes
214
+ list_dict = self .control_attributes [ ' textures' ] \
215
+ if main_key in self .control_attributes [ ' textures' ] \
216
+ else self .control_attributes [ ' attributes' ]
216
217
217
218
if main_key .endswith ("SLIDERDATA" ):
218
219
main_key = "SLIDERDATA"
220
+ if main_key == "ENTRYFIELDDATA" :
221
+ main_key = "TEXTENTRYDATA"
219
222
220
223
for d in list_dict [main_key ]:
221
224
if sub_key in d and d [sub_key ] != value :
222
225
d [sub_key ] = value
223
- # self.main_window.update_modified_state(True)
226
+ self .update_modified_state (True )
227
+
224
228
225
229
def update_texture_property (self , main_key , sub_key , image , value = None ):
226
- list_dict = self .control_attributes . textures
230
+ list_dict = self .control_attributes [ ' textures' ]
227
231
228
232
for d in list_dict [main_key ]:
229
- if 'image ' in d and d ['image ' ] == image and sub_key in d and d [sub_key ] != value :
233
+ if 'IMAGE ' in d and d ['IMAGE ' ] == image and sub_key in d and d [sub_key ] != value :
230
234
d [sub_key ] = value
231
- # self.main_window .update_modified_state(True)
235
+ self .update_modified_state (True )
232
236
233
237
def clear (self ):
234
238
"""Clear all widgets from the layout."""
@@ -291,8 +295,8 @@ def create_inner_section(title, parent, section_manager, object_name):
291
295
def filter_empty_properties (properties_list ):
292
296
return [
293
297
prop for prop in properties_list if not (
294
- 'image ' in prop and prop ['image ' ] == 'NoImage'
295
- and 'color ' in prop and prop ['color ' ] == (255 , 255 , 255 , 0 )
298
+ 'IMAGE ' in prop and prop ['IMAGE ' ] == 'NoImage'
299
+ and 'COLOR ' in prop and prop ['COLOR ' ] == (255 , 255 , 255 , 0 )
296
300
and 'BORDERCOLOR' in prop and prop ['BORDERCOLOR' ] == (255 , 255 , 255 , 0 )
297
301
)
298
302
]
0 commit comments