Generation

generate functionWed, 03 May 2023

haz un rectangulo con un circulo dentro con tkinter

import tkinter def rectangle_with_circle(canvas, x1, y1, x2, y2): canvas.create_rectangle(x1, y1, x2, y2) create_circle(canvas, (x1 + x2) / 2, (y1 + y2) / 2, abs(x1 - x2) / 2) def create_circle(canvas, x, y, radius) x0 = x - radius y0 = y - radius x1 = x + radius y1 = y + radius return canvas.create_oval(x0, y0, x1, y1) window = tkinter.Tk() canvas = tkinter.Canvas(window, width=500, height=500) canvas.pack() rectangle_with_circle(canvas, 100, 100, 200, 200) window.mainloop()

Questions about programming?Chat with your personal AI assistant