@danypo8327

Hola Diego. Hice algo similar a la otra aplicación pero ahora con diagrama tipo 'torta'
CÓDIGO 12/2023

from tkinter import *
from tkinter import ttk
class CircularCanvas:
    def __init__(self):
        # DISEÑO VENTANA
        self.ventana1 = Tk()
        self.ventana1.geometry("400x400")
        self.ventana1.title("Ejemplo SECTOR CIRCULAR - CANVAS")
        self.ventana1.resizable(1, 1)
        self.ventana1.config(bg="white")



        # Crear un LABEL FRAME
        self.stiker_titulado=LabelFrame(self.ventana1,text="Diagrama tipo 'Torta'")
        self.stiker_titulado.grid(row=0,column=0,padx=10,pady=10,sticky="w")

        # Crear ENTRY ---> Perteneciente al LABEL FRAME
        self.box = Entry(self.stiker_titulado,bg="black",fg="orange",font="Terminal 20",width=5)
        self.box.grid(row=0,column=0,pady=20,padx=5)
        # Crear LABEL ---> Perteneciente al LABEL FRAME
        self.etiq1=Label(self.stiker_titulado,text="Ingrese %",bg="white",fg="black",font="Arial 12")
        self.etiq1.grid(row=0,column=1,pady=20,padx=0)

        # Crear BOTÓN ---> Perteneciente al LABEL FRAME
        self.boton = ttk.Button(self.stiker_titulado, text="Dibujar TORTA",command=self.porcentage )
        self.boton.grid(row=0, column=2, sticky="w")
#---------------------------------------------------------------------------------------------------
        # Crear un Canvas
        self.canvas = Canvas(self.ventana1, width=300, height=300, bg="gray")
        self.canvas.grid(row=1, column=0,pady=20,padx=10)



# ---------------------------------
        self.ventana1.mainloop()

    # MÉTODO PARA EL BOTÓN
    def porcentage(self):
        self.canvas.delete(ALL)  # Borra  para poder mostrar lo generado acá.

        self.porcent= float(self.box.get())
        if self.porcent == 100:
            self.canvas.create_oval(10, 10, 250, 250,  fill="yellow") #Dibuja un círculo
            self.canvas.create_text(255, 50, text="100%", fill="white",font="Arial 12 bold")
        else:
            self.grados = self.porcent * 360 / 100
            # SECTOR CIRCULAR SOBRE EL CANVAS
            self.canvas.create_arc(10, 10, 250, 250, start=0, extent=self.grados, fill="yellow")
            # Texto sobre el diagrama
            self.canvas.create_text(255, 50, text=f"{self.porcent} %", fill="white",font="Arial 12 bold")

 # ppal.
aplicacion=CircularCanvas()