def syncPyToHtml(pyObj, htmlId = None): if htmlId == None: if id(pyObj) in htmlFromPyId: for h in htmlFromPyId[id(pyObj)]: syncPyToHtml(pyObj, h) return browser.jsCall("syncPyToHtml(" + browser.jsString(htmlId) + "," + str(id(pyObj)) + ")")
def addHtml(pyObj, htmlParentId = ""): if not id(pyObj) in htmlFromPyId: htmlFromPyId[id(pyObj)] = [] htmlIds = htmlFromPyId[id(pyObj)] if len(htmlIds) == 0: refnum = 0 else: lastrefnum = int(htmlIds[-1].split("-")[2]) refnum = lastrefnum + 1 htmlId = "py-" + str(id(pyObj)) + "-" + str(refnum) htmlIds += [ htmlId ] pyFromPyId[id(pyObj)] = pyObj browser.jsCall("__addHtmlPyNode(" + browser.jsString(htmlId) + "," + str(id(pyObj)) + "," + browser.jsString(htmlParentId) + ")") return htmlId