flare.utils

Utility functions.

Module Contents

Functions

unescape(val[, maxLength])

Unquotes several HTML-quoted characters in a string.

doesEventHitWidgetOrParents(event, widget)

Test if event 'event' hits widget 'widget' (or any of its parents).

doesEventHitWidgetOrChildren(event, widget)

Test if event 'event' hits widget 'widget' (or any of its children).

textToHtml(node, text)

Generates html nodes from text by splitting text into content and into line breaks html5.Br.

parseInt(s[, ret])

Parses a value as int.

parseFloat(s[, ret])

Parses a value as float.

createWorker(pythonCode[, callback, errorCallback, ...])

Generates and starts a Pyodide Webworker.

flare.utils.unescape(val, maxLength=0)

Unquotes several HTML-quoted characters in a string.

Parameters:
  • val (str) – The value to be unescaped.

  • maxLength (int) – Cut-off after maxLength characters. A value of 0 means “unlimited”. (default)

Returns:

The unquoted string.

Return type:

str

flare.utils.doesEventHitWidgetOrParents(event, widget)

Test if event ‘event’ hits widget ‘widget’ (or any of its parents).

flare.utils.doesEventHitWidgetOrChildren(event, widget)

Test if event ‘event’ hits widget ‘widget’ (or any of its children).

flare.utils.textToHtml(node, text)

Generates html nodes from text by splitting text into content and into line breaks html5.Br.

Parameters:
  • node – The node where the nodes are appended to.

  • text – The text to be inserted.

flare.utils.parseInt(s, ret=0)

Parses a value as int.

flare.utils.parseFloat(s, ret=0.0)

Parses a value as float.

flare.utils.createWorker(pythonCode, callback=None, errorCallback=None, context={})

Generates and starts a Pyodide Webworker.

def calllog(txt=None):

result = txt.data.to_py() if “error” in result:

print(result[“error”])

if “msg” in result:

print(result[“msg”])

code=’’’

import statistics,time from js import self as js_self for i in range(0,100):

js_self.postMessage(“POST %s”%i)

‘’’

createWorker(code,calllog,calllog)

context can take variables, these are like global startparameters