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
| #! /usr/bin/env python
# -*- coding: utf-8 -*-
from Tkinter import *
from math import *
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ animation
def manager(event) :
affichage(event)
def pixel(w, x, y, c) : # widget, abs, ord, color
w.create_rectangle(x, y, x, y, fill=c, outline=c)
def scale(val) : return round(val * H/3, 2)
def affichage(click) :
afficheur ['text'] = "Pas de : 10 \nX = 25 \nY = 150"
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ widgets
T = Tk()
T.title('Tangente 0.0')
W = 300 # width
H = 300 # height
F = Canvas(T,width=W, height=H, bg='light yellow')
F.pack()
X = W / 12 # decalage horizontal
Y = H / 2 # decalage verticale
F.create_line(-57*10, Y, 57*10, Y) # axe x
F.create_line(X, X, X, H-20) # axe
for angle in xrange(0, int(radians(360) * 100), 10) : # revolution complete
x = angle / 100.
y = scale(tan(x)) + Y
x = x * 10 + X # graduation
pixel(F, x, y, 'red') # tracage
F.bind("<Button-1>", manager)
afficheur = Label(T)
afficheur.pack()
T.mainloop() |
Partager