Make GH Python print() stay with buttons (disappear after a second)

Hi I have a button “z” connect to my gh python.
My print() will only stay for half a sec after I pressed the button then disappear
How can I make the print() stay, until the next time press the button again to update

sample code of a timer:

import time 

def main():
    time1=time.time()
    if z:
        time.sleep(1)
        print("aaa")
    time2=time.time()
    print("time :" + round(time2-time1,2).ToString())
    
main()

I just created similar functionality in a component I was working on with a button input. What you are after is called “sticky”.

you can store your print value or any other value in a new sticky dictionary along with a key and this value can be referenced later by retrieving if from the sticky dictionary by accessing it with the key value.

Here’s more info:

Rhino - Sticky Values.

1 Like