Closed martinlombana closed 3 years ago
No, only get
and set
methods:
element.set_style_attribute('class', 'dn')
dn = element.style_attribute('class')
There is no anything for add/remove/toggle/has class operations in C API, so you need to implement it yourself (unless Andrew adds those methods to API).
Okey!
In case someone is reading this and needs it, here it is, working, in extended descriptive code.
def add_class(self, element: Element, class_name):
current_classes = element.attribute('class')
if current_classes is None:
current_classes = ''
current_classes = current_classes.split()
if class_name in current_classes:
return
else:
current_classes.append(class_name)
element.set_attribute('class', ' '.join(current_classes))
def remove_class(self, element: Element, class_name):
current_classes = element.attribute('class')
if current_classes is None:
current_classes = ''
current_classes = current_classes.split()
if class_name not in current_classes:
return
else:
element.set_attribute('class', ' '.join([a for a in
current_classes if a not in [class_name]]))
BTW: Is there a complete set specifications for the underlying native API so I can take a look?
https://github.com/c-smile/sciter-sdk/blob/master/include/sciter-x-dom.h only this.
And a rendered version (but outdated): https://sciter.com/sdk/doc.api/html/sciter-x-dom_8h.html
I see that I can use:
To set a class. But is there any exposed function in the python api in order to replicate:
Or I have to do it myself? (It's trivial, but I don't want to replicate existing functions, and I haven't found this one). There is no exposed "attributes" property to the Element class.
If it is not added (and I am looking in the wrong place/methods), but exists in native C api, could you add it or point me how to add it?
BTW: Is there a complete set specifications for the underlying native API so I can take a look?
Thanks!