(self, widget)
| 763 | |
| 764 | |
| 765 | def set_widget(self, widget): |
| 766 | |
| 767 | if not self.__ref_widget is None: |
| 768 | if self.__ref_widget.identifier == widget.identifier: |
| 769 | self.update_widget() |
| 770 | return |
| 771 | self.__ref_widget = widget |
| 772 | |
| 773 | print("EditorAttributes set widget") |
| 774 | self.infoLabel.set_text("Selected widget: %s" % widget.variable_name) |
| 775 | |
| 776 | for w in self.attributeGroups.values(): |
| 777 | self.attributes_groups_container.remove_child(w) |
| 778 | |
| 779 | for w in self.attributesInputs: |
| 780 | if w.attributeDict['group'] in self.attributeGroups: |
| 781 | self.attributeGroups[w.attributeDict['group']].attributes_groups_container.remove_child(w) |
| 782 | |
| 783 | index = 100 |
| 784 | default_width = "100%" |
| 785 | default_height = "22px" |
| 786 | for x, y in inspect.getmembers(self.__ref_widget.__class__): |
| 787 | if type(y) == property: |
| 788 | if hasattr(y, "fget"): |
| 789 | if hasattr(y.fget, "editor_attributes"): |
| 790 | group = y.fget.editor_attributes['group'] |
| 791 | |
| 792 | attributeEditor = None |
| 793 | attributeDict = y.fget.editor_attributes |
| 794 | # 'background-repeat':{'type':str, 'description':'The repeat behaviour of an optional background image', ,'additional_data':{'possible_values':'repeat | repeat-x | repeat-y | no-repeat | inherit'}}, |
| 795 | if attributeDict['type'] in (bool, int, float, gui.ColorPicker.__name__, gui.DropDown.__name__, 'url_editor', 'css_size', 'base64_image', 'file'): |
| 796 | if attributeDict['type'] == bool: |
| 797 | chk = gui.CheckBox( |
| 798 | 'checked', width=default_width, height=default_height) |
| 799 | attributeEditor = EditorAttributeInputGeneric( |
| 800 | chk, self.__ref_widget, x, y, y.fget.editor_attributes, self.appInstance) |
| 801 | elif attributeDict['type'] == int: |
| 802 | spin = gui.SpinBox(attributeDict['additional_data']['default'], attributeDict['additional_data']['min'], attributeDict[ |
| 803 | 'additional_data']['max'], attributeDict['additional_data']['step'], width=default_width, height=default_height) |
| 804 | attributeEditor = EditorAttributeInputInt( |
| 805 | spin, self.__ref_widget, x, y, y.fget.editor_attributes, self.appInstance) |
| 806 | elif attributeDict['type'] == float: |
| 807 | spin = gui.SpinBox(attributeDict['additional_data']['default'], attributeDict['additional_data']['min'], attributeDict[ |
| 808 | 'additional_data']['max'], attributeDict['additional_data']['step'], width=default_width, height=default_height) |
| 809 | attributeEditor = EditorAttributeInputFloat( |
| 810 | spin, self.__ref_widget, x, y, y.fget.editor_attributes, self.appInstance) |
| 811 | elif attributeDict['type'] == gui.ColorPicker.__name__: |
| 812 | attributeEditor = EditorAttributeInputColor( |
| 813 | self.__ref_widget, x, y, y.fget.editor_attributes, self.appInstance) |
| 814 | elif attributeDict['type'] == gui.DropDown.__name__: |
| 815 | drop = gui.DropDown( |
| 816 | width=default_width, height=default_height) |
| 817 | for value in attributeDict['additional_data']['possible_values']: |
| 818 | drop.append(gui.DropDownItem(value), value) |
| 819 | attributeEditor = EditorAttributeInputGeneric( |
| 820 | drop, self.__ref_widget, x, y, y.fget.editor_attributes, self.appInstance) |
| 821 | elif attributeDict['type'] == 'url_editor': |
| 822 | attributeEditor = EditorAttributeInputUrl( |
no test coverage detected