create a cirlce in python

You can create a circle in Python using the tkinter module. Here is an example code to create a circle using tkinter:

main.py
import tkinter as tk

# create a tkinter window
root = tk.Tk()

# create a canvas to draw on
canvas = tk.Canvas(root, width=300, height=300)
canvas.pack()

# create a circle using canvas.create_oval() method
circle = canvas.create_oval(50, 50, 250, 250, fill="red")

# start the tkinter event loop
root.mainloop()
314 chars
15 lines

This code will create a window with a red circle on it. Note that the create_oval() method takes four arguments: the x-coordinate and y-coordinate of the top-left corner of the bounding box of the oval, and the x-coordinate and y-coordinate of the bottom-right corner of the bounding box of the oval. In our example, the bounding box of the oval is from (50, 50) to (250, 250), which makes it a circle.

related categories

gistlibby LogSnag