I am a beginner developer and I’ve been trying to code some basic tkinter shapes. When I run it in the pyhon-mage ide called IDLE, there is no problem. However, when I try to run it in visual studio, no window opens up. There is nothing written in console (only PS C:Usersmaria> & C:/Users/maria/AppData/Local/Programs/Python/Python312/python.exe c:/Users/maria/Desktop/Untitled-3.py)…
Can anybody help me please?
I expected to run the code in visual studio as well, not only in IDLE, but it doesn’t work.
Here is the code:
import tkinter, random
canvas = tkinter.Canvas()
canvas.pack()
colors = ["red", "green", "blue", "yellow", "orange", "purple", "pink"]
for i in range(20):
x = random.randint(10,300)
y = random.randint(10, 200)
canvas.create_rectangle(x, y, x+random.randint(5, 50), y+random.randint(5, 50), fill = colors[random.randint(0, len(colors)-2)])
This is what IDLE displays (this is what I want):
And this is what visual studio displays (nothing is displayed):
1