tracer une cercle dans python tkinter?

O

olsr.kamal

comment tracer une cercle contient un numéro au un symbole dans le center dans python tkinter?
 
P

Peter Otten

comment tracer une cercle contient un numéro au un symbole dans le center
dans python tkinter?

[I hope you can cope with English]

Use a Canvas widget:

import tkinter as tk

root = tk.Tk()
canvas = tk.Canvas(root, width=240, height=240)
canvas.pack()

canvas.create_oval((20, 20), (220, 220), width=10, fill="white")
tag = canvas.create_text(120, 120, text="42", justify=tk.CENTER,
font=("Helvetica", 110), fill="#800")

if 1: # fancy stuff; you can safely remove the complete if-statement

def n(x):
while True:
for i in reversed(range(x+1)):
yield i

values = n(42)
def down():
text = str(next(values))
canvas.itemconfig(tag, text=text)
root.after(300, down)

down()

root.mainloop()


See

http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/canvas.html

for more.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top