Python Forum

Full Version: setup() from turtle module not working
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I am trying to make changes in the turtle graphics window size. I tried using the screensize() and the setup() methods, but no success. The latest code was very simple:
from turtle import *
setup(600,500)
for i in range(7):
    forward(50)
    left(90)
    forward(50)
    right(90)
I have updated my Python version to 3.8 and running under Windows 8.1 pro. I tried everything.... It doesn't work. Thank you for your help.
(Oct-27-2019, 09:13 PM)bobfat Wrote: [ -> ]I have updated my Python version to 3.8 and running under Windows 8.1 pro. I tried everything.... It doesn't work. Thank you for your help.

Hi!

I ran your program on my Python 3.7.4 Shell and Windows 10, and it runs without any problems.

Did you check if it ran without any problems before updating your Python version to 3.8?

I've read here, on this site, that some people are having some trouble running some modules with Python 3.8. That may be also your case.

All the best,
Hi,

In fact, it doesn't give any kind of errors, the code runs OK, but simply not resizing the window.
(Oct-27-2019, 11:20 PM)bobfat Wrote: [ -> ]In fact, it doesn't give any kind of errors, the code runs OK, but simply not resizing the window.

Then, if you run this modification of your program, you can see if the window size really changes or not:

from turtle import *
setup(600,500)
for i in range(7):
    forward(50)
    left(90)
    forward(50)
    right(90)
setup(200,100)
for i in range(7):
    forward(50)
    left(90)
    forward(50)
    right(90)
All the best,
While I am testing, I tried the same code but I replaced the setup() method value: instead of using dimensions in pixels, I used percentage:
from turtle import *
setup(0.75,0.95)
for i in range(7):
    forward(50)
    left(90)
    forward(50)
    right(90)
I worked just fine. It solves the problem but I can't understand why it doesn't work when I use pixels.

Thank you very much!
(Oct-28-2019, 12:03 AM)bobfat Wrote: [ -> ]I tried the same code but [ ... ] instead of using dimensions in pixels, I used percentage:
from turtle import *
setup(0.75,0.95)
[ ... ] I can't understand why it doesn't work when I use pixels.

My understanding is that you are trying to set the dimensions of the window to less than a pixel per side, so I think there is a minimum default size of the turtle window.

All the best,
Thank you very much for your help.
(Oct-28-2019, 10:51 AM)bobfat Wrote: [ -> ]Thank you very much for your help.

You're welcome! Smile