MCPcopy Index your code
hub / github.com/pywebio/PyWebIO / getWidgetElement

Function getWidgetElement

webiojs/src/models/output.ts:275–301  ·  view source on GitHub ↗
(spec: any)

Source from the content-addressed store, hash-verified

273 type2widget[w.handle_type] = w;
274
275export function getWidgetElement(spec: any) {
276 if (!(spec.type in type2widget))
277 throw Error("Unknown type in getWidgetElement() :" + spec.type);
278
279 let elem = type2widget[spec.type].get_element(spec);
280 if (elem.length != 1)
281 elem = $(document.createElement('div')).append(elem);
282
283 if (spec.style) {
284 // add style attribute
285 let old_style = elem.attr('style') || '';
286 elem.attr({"style": old_style + ';' + spec.style});
287 }
288 if (spec.click_callback_id) {
289 elem.on('click', (e) => {
290 pushData(null, spec.click_callback_id);
291 });
292 elem.addClass('pywebio-clickable');
293 }
294 if (spec.container_dom_id) {
295 if (spec.container_selector)
296 elem.find(spec.container_selector).attr('id', spec.container_dom_id);
297 else
298 elem.attr('id', spec.container_dom_id);
299 }
300 return elem;
301}
302
303
304export function render_tpl(tpl: string, data: { [i: string]: any }) {

Callers 2

handle_messageMethod · 0.90
render_tplFunction · 0.85

Calls 4

pushDataFunction · 0.90
appendMethod · 0.80
get_elementMethod · 0.65
$Function · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…