Bonjour,
je voudrais obtenir le résultat suivantNom : cap2.png
Affichages : 301
Taille : 8,2 Ko,
mais j'obtiens en fait Nom : cap1.png
Affichages : 286
Taille : 8,3 Ko
avec le programme ci-dessous :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#! python3
# coding: utf-8
 
'''
https://apcpedagogie.com/dessiner-avec-un-canvas-tkinter/#create_oval
'''
 
##----- Importation des Modules -----##
import os.path, sys
from tkinter import *
import tkinter as tk 
import tkinter.font as tkFont
from tkinter import filedialog
import math
 
##----- Variables globales -----##
LARGEUR = 300
HAUTEUR = 300
PI = 3.1416
A = (50, 50)      # point haut-gauche du carré
B = (250, 250)    # point bas-droite du carré
R = int((B[0]-A[0]) / 2)                              # rayon
C = (int((A[0] + B[0]) / 2), int((A[1] + B[1]) / 2))  # centre du cercle
couleur  = [[120, 'light blue'],[130, 'orange'], [140, 'white'],
            [150, 'grey'], [160, 'yellow'],
            [170, 'white'], [180, 'light blue'], [190, 'white'], [1000, 'green']]   
 
##----- Définition des Fonctions -----##
def test():
    inc_v = (B[1] - A[1]) / 20   # incrément vertical pour 10° 
    deb = 0
    fin = 10
    for i in range(10):
        dessin.create_arc(A, B, outline="red", extent=fin, start=deb, fill=couleur[i%len(couleur)][1], width=1)
        hauteur = round(R * math.tan(PI * 10 * i / 360))
        hor = int(R * math.cos(PI * 10 * i /360))
        v = C[1] - hauteur 
        h = C[0] + hor + 5
        dessin.create_text(h, v, text=str(fin), anchor='w',  fill='black')    # texte externe
        deb = fin
        fin += 10
 
 
##----- Création de la fenêtre -----##
fen = Tk()
fen.title('camembert')
 
##----- Création des boutons -----##
 
##----- Création du canevas -----##
dessin=Canvas(fen, bg="ivory", width=LARGEUR, height=HAUTEUR)
dessin.grid(row = 1, column = 0, columnspan = 2, padx=5, pady=5)
 
##----- Objets graphiques -----##
dessin.create_oval(A, B,outline="light blue", width=3)
 
##----- Programme principal -----##
test()
fen.mainloop()# Boucle d'attente des événements
Je ne vois pas où se trouve l'erreur.
Merci pour votre aide