Hello,
Does anyone know if it is possible to update the text inside of a label in the VPython shell? I am trying to make a visible counter/timer, and I would prefer it to be in the shell rather than the print statement window.
So far I have tried to set the text equal to the variable:
variable = 0 #Initial value of variable
label(pos=(0,0,0),text = variable)
#Variable then gets updated in a loop
I have also tried to create new labels to go on top of the previous ones as the counter progresses:
condition = false #Initial condition
label(pos = (0,0,0), text = '0')
#Inside of loop:
#Update condition
#if condition = true:
label(pos = (0,0,0),text='1')
#if condition = true again:
label(pos = (0,0,0),text='2')
Please keep in mind I am trying to outline my general methodology for simplification purposes. This is not my actual code! So far, neither method has worked. The first program yields the error message:
ArgumentError: Python argument types in
None.None(label, int)
did not match C++ signature:
None(cvisual::label {lvalue}, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >)
I realize the error comes from me not putting text = 'variable', but then it just prints the word variable and no longer a number that I can update.
The second program almost works. It does print a new label over the old one, but not when I want it to. Because of this I figured I had made an error in the part of the code I labeled #if condition = true. Nope. I tested it, and it works when I create a print statement for the other window, but I want the print statement to be in the same window as the simulation!
I would greatly appreciate it if someone could share their solution, if they have one, to this particular problem. I hope I have provided enough information.
Thank you!