Speech and thought bubbles in Python

Hi,

In the documentation of the API it is written that the speech and thought is in the Union type such as Union[str, float].
What is the float used for? Is it the time/seconds for which the bubble would be shown? If so, how do we declare it other than:
item.speech = “Hello”

If it is not used for the time that the bubble would be shown, how to recreate the CoBlocks’ block " say “smth” for X seconds"?

Hi @ami566 I’m no Python expert, so I googled “python Union type” and found this: https://coderslegacy.com/python/union-in-typing/

This is a special keyword, which allows us to specify multiple allowed datatypes, instead of a single one.

So it simply means you can use text or numbers in the speech/thought bubbles, e.g:

item.speech = 3.456

or

item.thought = "I wonder..."

Hope this helps! Let me know if you have any further questions about this. If this solves your problem, please mark this post as the Solution.

Many thanks,
Geoff @ TechLeap

2 Likes

Hi, @techleapnz . Your response answers my question, for which I am very grateful to you!
However, I thought that the float had different pusrpose, such as the time the bubble to be shown, but I guess that function would be implemented in a different way, probably with the time.schedule.
Again, thank you!

1 Like