What I’m trying to do:
I added an alert in a class init method and noticed it being raised twice if my object was constructed within the alert. I might be explaining things poorly , so lets just look at the code!
The following button clicks yield different results:
def button_1_click(self, **event_args):
"""This method is called when the button is clicked"""
alert(content=Form2())
def button_2_click(self, **event_args):
"""This method is called when the button is clicked"""
alert_form = Form2()
alert(alert_form)
button_1_click will fire the init method of Form2 twice and button_2_click will call the init method once.
Cool–Thanks! I just found the same issue causing my forms to take twice as long to init and came to find anything similar to fix what I might be doing wrong.
After trying to look into it as far as I can tell, if they have different ID’s they are different objects. Javascript does not allow skulpt to gain access to the memory address of the object like in normal python, so when an object is created it gets assigned an id that is pretty much just an integer that counts up from 0.
So the first object ID skulpt makes is 0, then the next is 1, 2 , 3 etc.
If the results of id() do not match they are not the same object in Javascript, skulpt, or python, since the id seems to just be assigned by some global id value that increments by one at each creation of a new object.
Which makes me wonder, if your skulpt code sits there churning out new, then destroying objects all day 24/7 will it eventually all go sideways if it creates more than 2147483647 objects.