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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
| # -*- coding:utf-8 -*-
#
#Dessin des tables de multiplications
#en Rosaces modulo 360.
#
from tkinter import *
from math import pi
from math import cos
from math import sin
def dessin(yy,xx):
global flag
flag=False
can.delete(ALL)
y=yy
x=1
xmax=xx
angle=(2*pi)/xmax
while x<xmax+1:
z=y*x
a1=0-(((x%xmax)*angle)-(pi/2))
a2=0-(((z%xmax)*angle)-(pi/2))
x1,y1=275+250*cos(a1),275-250*sin(a1)
x2,y2=275+250*cos(a2),275-250*sin(a2)
can.create_line(x1,y1,x2,y2,width=1,fill="black")
x=x+1
txt="Multiplications de "+str(yy)+" modulo "+str(xx)
lab.configure(text=txt,bg="black",fg="white")
def valeury(retour2):
global xx
global yy
yy=int(retour2)
if xx<10:
xx=10
dessin(yy,xx)
def valeurxmax(retour1):
global xx
global yy
xx=int(retour1)
if yy<2:
yy=2
dessin(yy,xx)
global yy
yy=1
global xx
xx=10
global flag
flag=True
fen=Tk()
fen.title("Rosaces 3.3")
s1=Scale(fen,length=711,orient=HORIZONTAL,label="Modulo",
troughcolor="dark grey",sliderlength=11,
showvalue=10,from_=10,to=720,tickinterval=50,
command=valeurxmax)
s1.pack(side=BOTTOM)
lab=Label(fen)
lab.pack(side=BOTTOM)
can=Canvas(fen,bg="white",height=550,width=550)
can.pack(side=LEFT)
s2=Scale(fen,length=399,orient=VERTICAL,label="Base",
troughcolor="dark grey",sliderlength=11,
showvalue=2,from_=2,to=200,tickinterval=10,
command=valeury)
s2.pack(side=TOP)
b1=Button(fen,text="Quitter",command=fen.destroy)
b1.pack(side=BOTTOM)
if flag:
dessin(2,10)
fen.mainloop() |