tolgaatam / ColabTurtle

An HTML based Turtle implementation, in order to work in Google Colab
MIT License
55 stars 30 forks source link

Request for getter-functions #2

Closed magnuskson closed 3 years ago

magnuskson commented 4 years ago

Hi, Thank you for creating Turtle for Colab.

I think it would be useful with functions that returns the current color, background, window size and pen width.

I have seen that there are global variables for these properties in your code, but when I try to use them they only contain the original default value even after I change a value. For example if I print(pen_color) it says "white" even though I've changed it and the pen draws with another color. I guess that this has something to do with global variables, and I have tried adding the global keyword but that does not help.

One example when this would be useful is to check that I don't change the pen to the same color as the current background. It would also be useful to know the window size from within the code.

If I paste the entire ColabTurtle code into a cell it works, but if I install it doesn't. You can see an example here: Install: https://colab.research.google.com/drive/1kyv1dC1z9x_2KuUGoYSSV1cU3faOeCT9 Paste: https://colab.research.google.com/drive/1kFDaAi6oKQKhu5q2sO5V4FpNQcK0MLT-

tolgaatam commented 3 years ago

Hi @magnuskson, thanks for the issue. I had left my notifications off, so I see this issue only now 🤦

As you imported the variables in the beginning and the values are primitive values, they are copied during import. So, it is pretty normal that their unchanged version is exposed to your main program. The solution sure would be implementing getter functions from the ColabTurtle module. Are you still interested in this improvement, though?

magnuskson commented 3 years ago

Thanks for your reply @tolgaatam . I haven't used turtles for a while. I don't think I will use it in the future either, at least not in the Colab environment. So I have no need for this functionality.

tolgaatam commented 3 years ago

Thanks for your input anyways, I have updated the project and added all the functions that you requested, along with many other standard turtle API. If you restart using turtle on colab some day, feel free to come with your new suggestions. I will see them on time, hopefully.

tolgaatam commented 3 years ago

Closing as the discussion is over.