MCPcopy Index your code
hub / github.com/rawpython/remi / EditorAttributeInputUrl

Class EditorAttributeInputUrl

editor/editor_widgets.py:1089–1130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1087
1088
1089class EditorAttributeInputUrl(EditorAttributeInputBase):
1090 inputWidget = None
1091
1092 def __init__(self, widget, attributeName, propertyDef, attributeDict, appInstance, *args, **kwargs):
1093 super(EditorAttributeInputUrl, self).__init__(widget, attributeName,
1094 propertyDef, attributeDict, appInstance, *args, **kwargs)
1095 self.inputWidget = gui.TextInput(width="100%", height="100%")
1096 self.inputWidget.onchange.do(self.on_attribute_changed)
1097 self.inputWidget.attributes['title'] = attributeDict['description']
1098
1099 self.btFileFolderSelection = gui.Widget(width='100%', height='100%')
1100 self.btFileFolderSelection.style.update({'background-repeat': 'no-repeat',
1101 'background-image': "url('/res:folder.png')",
1102 'background-color': 'transparent'})
1103 self.btFileFolderSelection.onclick.do(
1104 self.on_file_selection_bt_pressed)
1105 '''
1106 self.set_from_asciiart("""
1107 |del|lbl |input |bt|
1108 """)
1109 '''
1110 self.style.update({'grid-template-columns': "6% 46% 33% 15%",
1111 'grid-template-rows': "100%", 'grid-template-areas': "'del lbl input bt'"})
1112 self.append({'del': self.removeAttribute, 'lbl': self.label,
1113 'input': self.inputWidget, 'bt': self.btFileFolderSelection})
1114
1115 def on_file_selection_bt_pressed(self, widget):
1116 self.selectionDialog = gui.FileSelectionDialog(
1117 'Select a file', '', False, './', True, False)
1118 self.selectionDialog.confirm_value.do(self.file_dialog_confirmed)
1119 self.selectionDialog.show(self.appInstance)
1120
1121 def file_dialog_confirmed(self, widget, fileList):
1122 if len(fileList) > 0:
1123 self.inputWidget.set_value(
1124 "url('/editor_resources:" + fileList[0].split('/')[-1].split('\\')[-1] + "')")
1125 return self.on_attribute_changed(None, self.inputWidget.get_value())
1126
1127 def set_value(self, value):
1128 self.set_valid(not value is None)
1129 if not value is None:
1130 self.inputWidget.set_value(value)
1131
1132
1133class EditorAttributeInputBase64Image(EditorAttributeInputUrl):

Callers 1

set_widgetMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected