Bonjour

La calculette des gammes musicales écrite en python progresse.
Et c'est tant bien que mal, que j'espère parvenir à l'affichage des gammes.
Comme je n'ai jamais utilisé de tabulation, pour la mise en ligne/colonne du texte.
Peut-être auriez-vous une idée simple

Pour l'instant, l'application effectue des écritures sur l'EDI
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
 
# *
# Application gammique évolutive
# Version 1 : Calculer les gammes
#
from tkinter import *
 
class Gammique(Tk):
    """ Ramification Gammique """
    def __init__(self):
        Tk.__init__(self)
        "Tableau de bord"
        self.title('Entité Gammique :')
# Fenêtre écran_résultat
        self.can=Canvas(self,bg='white', height=500,width=750)
        self.can.pack(side=RIGHT)
        self.can.delete(ALL)
        # Tracé d'encadrement
        # Données de l'encadré : Axes(x,y)=365(x),220(y)
        self.can.create_line(10, 0, 10, 450, fill ='black')
        self.can.create_line(740, 10, 0, 10, fill ='blue')
        self.can.create_line(740, 450, 740, 10, fill ='black')
        self.can.create_line(10, 450, 740, 450, fill ='blue')
        # Bouton gamme_audio
        Button(self,text ='Radio_inactive',width=25).pack()
# Les notes cursives scalpha : Graduations gérées.
        self.sca1=Scale(self,length =250,orient = HORIZONTAL,label ='C',
              troughcolor ='black',sliderlength =20,showvalue =1,
              from_ =0,to =5,tickinterval =1,command=self.scanote1)
        self.sca1.pack()
        self.sca2=Scale(self,length =250,orient = HORIZONTAL,label ='D',
              troughcolor ='green',sliderlength =20,showvalue =1,
              from_ =-1,to =4,tickinterval =1,command=self.scanote2)
        self.sca2.pack()
        self.sca3=Scale(self,length =250,orient = HORIZONTAL,label ='E',
              troughcolor ='blue',sliderlength =20,showvalue =1,
              from_ =-2,to =3,tickinterval =1,command=self.scanote3)
        self.sca3.pack()
        self.sca4=Scale(self,length =250,orient = HORIZONTAL,label ='F',
              troughcolor ='grey',sliderlength =20,showvalue =1,
              from_ =-2,to =3,tickinterval =1,command=self.scanote4)
        self.sca4.pack()
        self.sca5=Scale(self,length =250,orient = HORIZONTAL,label ='G',
              troughcolor ='red',sliderlength =20,showvalue =1,
              from_ =-3,to =2,tickinterval =1,command=self.scanote5)
        self.sca5.pack()
        self.sca6=Scale(self,length =250,orient = HORIZONTAL,label ='A',
              troughcolor ='orange',sliderlength =20,showvalue =1,
              from_ =-4,to =1,tickinterval =1,command=self.scanote6)
        self.sca6.pack()
        self.sca7=Scale(self,length =250,orient = HORIZONTAL,label ='B',
              troughcolor ='yellow',sliderlength =20,showvalue =1,
              from_ =-5,to =0,tickinterval =1,command=self.scanote7)
        self.sca7.pack()
# Concerne les notes scahuit : Graduations gérées.
        self.sca8=Scale(self,length =250,orient = HORIZONTAL,label ='CDEFGAB_inactif',
              troughcolor ='ivory',sliderlength =20,showvalue =1,
              from_ =-12,to =12,tickinterval =1,command=self.scanote8)
        self.sca8.pack()
        # Bouton gamme_naturelle
        Button(self,text ='Zéro',width=25,command=self.zero).pack()
        # Bouton gamme_calculée
        Button(self,text ='Gamme',width=25,command=self.gama).pack()
        # Texte significatif
        lab=Label(self,text="Barre des tâches_inactive ").pack(side=RIGHT)
# Définition des curseurs
    def scanote1(self,xc):
        do=int(xc)
        xsi=self.sca7.get()
        xre=self.sca2.get()
        if do<xsi:self.sca7.set(do)
        if do>xre+1 :self.sca2.set(do-1)
    def scanote2(self,xd):
        re=int(xd)
        xdo=self.sca1.get()
        xmi=self.sca3.get()
        if re<xdo-1:self.sca1.set(re+1)
        if re>xmi+1 :self.sca3.set(re-1)
    def scanote3(self,xe):
        mi=int(xe)
        xre=self.sca2.get()
        xfa=self.sca4.get()
        if mi<xre-1:self.sca2.set(mi+1)
        if mi>xfa:self.sca4.set(mi)
    def scanote4(self,xf):
        fa=int(xf)
        xmi=self.sca3.get()
        xsol=self.sca5.get()
        if fa<xmi:self.sca3.set(fa)
        if fa>xsol+1:self.sca5.set(fa-1)
    def scanote5(self,xg):
        sol=int(xg)
        xfa=self.sca4.get()
        xla=self.sca6.get()
        if sol<xfa-1:self.sca4.set(sol+1)
        if sol>xla+1:self.sca6.set(sol-1)
    def scanote6(self,xa):
        la=int(xa)
        xsol=self.sca5.get()
        xsi=self.sca7.get()
        if la<xsol-1:self.sca5.set(la+1)
        if la>xsi+1:self.sca7.set(la-1)
    def scanote7(self,xb):
        si=int(xb)
        xla=self.sca6.get()
        xdo=self.sca1.get()
        if si<xla-1:self.sca6.set(si+1)
        if si>xdo:self.sca1.set(si)
    def scanote8(self,xh):
        sch=int(xh)
    def zero(self):
        self.can.delete(ALL)
        # Tracé d'encadrement
        # Données de l'encadré : Axes(x,y)=365(x),220(y)
        self.can.create_line(10, 0, 10, 450, fill ='black')
        self.can.create_line(740, 10, 0, 10, fill ='blue')
        self.can.create_line(740, 450, 740, 10, fill ='black')
        self.can.create_line(10, 450, 740, 450, fill ='blue')
        self.can.create_line(360, 450, 360, 10, fill ='olive')
        self.can.create_line(10, 220, 740, 220, fill ='olive')
        self.sca1.set(0)
        self.can.create_oval(300-5,220-5,300+5,220+5,fill='black')
        self.sca2.set(0)
        self.can.create_oval(320-5,220-5,320+5,220+5,fill='green')
        self.sca3.set(0)
        self.can.create_oval(340-5,220-5,340+5,220+5,fill='blue')
        self.sca4.set(0)
        self.can.create_oval(350-5,220-5,350+5,220+5,fill='grey')
        self.sca5.set(0)
        self.can.create_oval(370-5,220-5,370+5,220+5,fill='red')
        self.sca6.set(0)
        self.can.create_oval(390-5,220-5,390+5,220+5,fill='orange')
        self.sca7.set(0)
        self.can.create_oval(410-5,220-5,410+5,220+5,fill='yellow')
    def gama(self):
        self.can.delete(ALL)
        # Tracé d'encadrement
        # Données de l'encadré : Axes(x,y)=365(x),220(y)
        self.can.create_line(10, 0, 10, 450, fill ='black')
        self.can.create_line(740, 10, 0, 10, fill ='blue')
        self.can.create_line(740, 450, 740, 10, fill ='black')
        self.can.create_line(10, 450, 740, 450, fill ='blue')
        self.can.create_line(360, 450, 360, 10, fill ='olive')
        self.can.create_line(10, 220, 740, 220, fill ='olive')
# De la table gammique aux tables diatoniques
        gammes =[[1,1,0,1,1,1,0],[0,2,0,1,1,1,0],[2,0,0,1,1,1,0],[4,0,0,0,0,1,0],[1,0,1,1,1,1,0],[0,1,1,1,1,1,0],
                 [1,0,3,0,0,1,0],[1,2,1,0,0,1,0],[2,2,0,0,0,1,0],[0,0,1,2,1,1,0],[1,3,0,0,0,1,0],[0,0,2,1,1,1,0],
                 [1,2,2,0,0,0,0],[0,0,4,0,0,1,0],[1,4,0,0,0,0,0],[1,0,0,2,1,1,0],[0,1,0,2,1,1,0],[1,1,3,0,0,0,0],
                 [0,0,0,3,1,1,0],[1,1,0,0,2,1,0],[0,2,0,0,2,1,0],[0,2,0,2,0,1,0],[2,0,0,0,2,1,0],[1,0,1,0,2,1,0],
                 [1,0,1,2,0,1,0],[1,1,1,2,0,0,0],[2,0,0,3,0,0,0],[0,0,2,0,2,1,0],[1,2,0,2,0,0,0],[1,0,0,3,0,1,0],
                 [1,0,0,1,2,1,0],[1,1,0,3,0,0,0],[1,1,2,1,0,0,0],[0,1,0,0,3,1,0],[0,0,1,0,3,1,0],[0,0,0,1,3,1,0],
                 [0,0,0,2,2,1,0],[1,0,0,0,3,1,0],[0,0,2,2,0,1,0],[0,0,0,0,4,1,0],[0,0,2,3,0,0,0],[1,0,0,4,0,0,0],
                 [0,0,0,5,0,0,0],[1,1,0,1,0,2,0],[1,1,0,1,2,0,0],[0,2,0,1,0,2,0],[0,2,0,1,2,0,0],[2,0,0,1,0,2,0],
                 [2,0,0,1,2,0,0],[1,0,1,1,0,2,0],[1,0,1,1,2,0,0],[1,1,0,0,1,2,0],[1,1,0,0,3,0,0],[1,1,0,2,1,0,0],
                 [1,1,2,0,1,0,0],[0,2,0,0,0,3,0],[1,0,0,2,2,0,0],[1,0,0,1,0,3,0],[1,3,0,0,1,0,0],[1,0,0,0,1,3,0],
                 [0,0,0,3,0,2,0],[0,0,2,1,2,0,0],[1,0,0,0,0,4,0],[0,0,0,3,2,0,0],[1,1,0,0,0,3,0],[3,0,0,0,0,2,0]]
# Récupération des notes cursives
        ydo=self.sca1.get()
        xcpos_=300
        ycpos_=220
        xc_=xcpos_+(ydo*10)
        yc_=ycpos_-(ydo*10)
        rc_=5
        self.can.create_oval(xc_-rc_,yc_-rc_,xc_+rc_,yc_+rc_,fill='black')
        yre=self.sca2.get()
        xcpos_=320
        ycpos_=220
        xd_=xcpos_+(yre*10)
        yd_=ycpos_-(yre*10)
        rd_=5
        self.can.create_oval(xd_-rd_,yd_-rd_,xd_+rd_,yd_+rd_,fill='green')
        ymi=self.sca3.get()
        xcpos_=340
        ycpos_=220
        xe_=xcpos_+(ymi*10)
        ye_=ycpos_-(ymi*10)
        re_=5
        self.can.create_oval(xe_-re_,ye_-re_,xe_+re_,ye_+re_,fill='blue')
        yfa=self.sca4.get()
        xcpos_=350
        ycpos_=220
        xf_=xcpos_+(yfa*10)
        yf_=ycpos_-(yfa*10)
        rf_=5
        self.can.create_oval(xf_-rf_,yf_-rf_,xf_+rf_,yf_+rf_,fill='grey')
        ysol=self.sca5.get()
        xcpos_=370
        ycpos_=220
        xg_=xcpos_+(ysol*10)
        yg_=ycpos_-(ysol*10)
        rg_=5
        self.can.create_oval(xg_-rg_,yg_-rg_,xg_+rg_,yg_+rg_,fill='red')
        yla=self.sca6.get()
        xcpos_=390
        ycpos_=220
        xa_=xcpos_+(yla*10)
        ya_=ycpos_-(yla*10)
        ra_=5
        self.can.create_oval(xa_-ra_,ya_-ra_,xa_+ra_,ya_+ra_,fill='orange')
        ysi=self.sca7.get()
        xcpos_=410
        ycpos_=220
        xb_=xcpos_+(ysi*10)
        yb_=ycpos_-(ysi*10)
        rb_=5
        self.can.create_oval(xb_-rb_,yb_-rb_,xb_+rb_,yb_+rb_,fill='yellow')
# Mesure de l'intervalle tempéré
        c1=(yre+1)-ydo
        d2=(ymi+1)-yre
        e3=yfa-ymi
        f4=(ysol+1)-yfa
        g5=(yla+1)-ysol
        a6=(ysi+1)-yla
        b7=i=cum_diat=ok=x=0
        diata=[c1,d2,e3,f4,g5,a6,b7]
        while i < 6:
            cum_diat += diata[i]
            i+=1        
        diata[i]=5-cum_diat
        print('diata ',diata)
# Recherche diatonique par l'itération
        cc1=dd2=ee3=ff4=gg5=aa6=bb7=0
        diata2=[cc1,dd2,ee3,ff4,gg5,aa6,bb7]
        while x < 7:
            m=x
            y=0
            while y < 7:
                diata2[y]=diata[m]
                y+=1
                m+=1
                if m > 6:
                    m=0            
            myx=0
            for my in gammes:
                if diata2 == my:
                    degre=x
                    x=7
                    print('fin_1 ', degre,'my',myx,my)
                myx+=1
            x+=1
# Ici : diata(original cursif).degre(tonique).my(gamme)
# Définition diatonique
        # GMAJ= gammes[0]
        gmaj = [1,1,0,1,1,1,0]      # Forme majeure simplifiée
        # GNAT= Ordre cursif comme diata[]
        gnat = ['C','D','E','F','G','A','B']        # Forme alphabétique
        cnat = ['','','','','','','']
        # Niveaux d'altérations
        nordiese = ['','+','x','^','+^','x^','^^','+^^','x^^','^^^','+^^^','x^^^','^^^^']
        subemol = ['','****','°***','-***','***','°**','-**','**','°*','-*','*','°','-']
        # Configuration modale
        gdeg = ['I','II','III','IV','V','VI','VII']
        # Définition des notes cursives
        cursifs=[ydo,yre,ymi,yfa,ysol,yla,ysi]
        ynat=ymod=0
        for ycurs in cursifs:
            if ycurs > 0 :
                ymod=nordiese[ycurs]
            if ycurs < 0 :
                ymod=subemol[ycurs]
            if ycurs == 0 :
                ymod=subemol[ycurs]
            cnat[ynat]=ymod
            #print('ymod ',ymod)
            ynat+=1
# Une tournée produit une tonalité modale de 7 notes
        nat2=degre
        deg = 0
        while deg < 7 :
            nat = deg       # Degré tonal en question
            cri = gimj = gmod = maj = 0
            while maj < 7 : # Tonalité modale du degré
                gmj = gmaj[maj]     # Forme majeure (1101110)
                imaj = diata2[nat]  # Forme modale (DIATA[DEGRE])
                ynt = cnat[nat2]   # Forme altérative
                gnt = gnat[nat2]     # Forme tonale (CDEFGAB)
                ideg = gdeg[deg]
                #print('ynt,gnt ',ynt,gnt)
                cri = cri + gimj    # Tonalité cumulée
                gimj = imaj - gmj   # Calcul tonal PAS/PAS
                #print ("gimj,cri,gnt ",gimj,cri,gnt)
                cmod = gmod = cri
                #print ("gmod ",gmod,gnt)
                if gmod > 0 :
                    imod = nordiese[cmod]
                    #print ("imod+cmod",imod,cmod,gnt)
                if gmod < 0 :
                    imod = subemol[cmod]
                    #print ("imod-cmod",imod,cmod,gnt)
                if gmod == 0 :
                    imod = subemol[cmod]
                #print ("imod,cmod ",imod,cmod,gnt)
                gmod = gmod + cri   # Transition tonale
                nat+=1
                nat2+=1
                if nat > 6 :
                    nat = 0
                if nat2 > 6 :
                    nat2 = 0
                maj = maj + 1 
                print ("ynt,gnt,imod,maj ",ynt,gnt,imod,maj)
                #
            nat2+=1
            if nat2 > 6 :
                    nat2 = 0
            print ("___",ideg)
            deg = deg + 1
            #
Gammique().mainloop()
Ne faites pas attention aux #print , ils m'ont aidés à tester certains résultats, ils sont à effacer une fois qu'ils deviennent inutiles