IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Tkinter Python Discussion :

Le widget-bouton invisible


Sujet :

Tkinter Python

  1. #1
    Invité
    Invité(e)
    Par défaut Le widget-bouton invisible
    Banjo 8^)
    Je suis enfin parvenu à gérer les boutons radio, à ma façon soit : épicerie fine, et variables rigolotes...
    Mais pour poursuivre mon inébranlable empilement jusqu'à plus de fenêtre, j'ai besoin de rendre invisible un bouton d'invocation. Je préfèrerai qu'il ne prenne pas du tout de place à l'écran, pour ne garder que son côté utile...
    self.btfictif=Button(self, command=self.yoiioiioy)
    self.btfictif.pack()
    Ceci est le bouton que je souhaite invisible
    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
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
     
    #!/usr/bin/env python 
    # -*- coding: utf-8 -*-
    # *
    # Application gammique évolutive
    # Version 1 : Calculer les gammes
    #
    from tkinter import *
    #import winsound
     
    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)
                    # Tracé d'encadrement
                    # Données de l'encadré : Axes(x,y)=365(x),220(y)
                    self.can.delete(ALL)
                    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')
     
                    # Fenêtre des utilités
                    self.cad=Frame(self,width=300,height=600)
                    self.cad.pack(side=LEFT)
                    # Bouton gamme_audio
                    #winsound.Beep(frequency, duration)
                    self.btrad=Button(self.cad,text ='Radio_inactive',width=15,bg='light blue')
                    self.btrad.pack()
                    # Bouton choix chromatique
                    self.btchr=Button(self.cad,text ='Chrome_inactif',width=15,bg='light blue')
                    self.btchr.pack()
                    # Bouton tableaux instruments
                    self.bttab=Button(self.cad,text ='Tabla_inactif',width=15,bg='light blue')
                    self.bttab.pack()
                    # Bouton accords1357
                    self.bta13=Button(self.cad,text ='A1357_inactif',width=15,bg='light blue')
                    self.bta13.pack()
     
                    # Groupe Octave RADIO
                    self.rad=[
                            Radiobutton(
                                    self.cad,
                                    variable=variable,
                                    text=text,
                                    value=value,
                                    command=command,
                            )for (variable, text, value,command) in (
                                    ("yioiy","Octave -1", "ioy",self.yoi),
                                    ("yioiy","Octave  0", "ioi",self.ioi),
                                    ("yioiy","Octave +1", "yoi",self.ioy),
                            )
                    ]
                    for i in self.rad: i.pack()
                    self.rad[1].select()
     
                    # Mémoire de forme d'octave
                    self.ent= Entry(self,bg='orange',font='bold')
                    self.ent.pack()
                    self.ent.delete(0,END)
                    self.ent.insert(END,"IOI")
     
                    # Les notes cursives scalpha : Graduations gérées.
                    self.sca=[
                            Scale(
                                    self,
                                    length=250,
                                    orient=HORIZONTAL,
                                    label=label,
                                    troughcolor=color,
                                    sliderlength=20,
                                    showvalue=1,
                                    from_=f,
                                    to=t,
                                    tickinterval=1,
                                    command=command,
                            ) for (label, color, f, t, command) in (
                                    ("C", "black", 0, 5, self.scanote1),
                                    ("D", "green", -1, 4, self.scanote2),
                                    ("E", "blue", -2, 3, self.scanote3),
                                    ("F", "grey", -2, 3, self.scanote4),
                                    ("G", "red", -3, 2, self.scanote5),
                                    ("A", "orange", -4, 1, self.scanote6),
                                    ("B", "yellow", -5, 0, self.scanote7),
                                    ("CDEFGAB", "ivory", -5, 5, self.scanote8),
                            )
                    ]
                    for x in self.sca: x.pack()
     
                    # Bouton gamme_naturelle
                    self.btzer=Button(self,text ='Zéro',width=25,command=self.zero)
                    self.btzer.pack()
                    # Bouton gamme_calculée
                    self.btgama=Button(self,text='gamme',width=25,command=self.gama)
                    self.btgama.pack()
                    # Bouton de relais fantôme 
                    self.btfictif=Button(self, command=self.yoiioiioy)
                    self.btfictif.pack()
            # __init__()
     
            # Les octaves du groupe RADIO
            def yoiioiioy(self):
                    xrad=self.ent.get()
            def yoi(self):
                    self.ent.delete(0,END)
                    self.ent.insert(END,"YOI")
                    self.btfictif.invoke()
            def ioi(self):
                    self.ent.delete(0,END)
                    self.ent.insert(END,"IOI")
                    self.btfictif.invoke()
            def ioy(self):
                    self.ent.delete(0,END)
                    self.ent.insert(END,"IOY")
                    self.btfictif.invoke()
            # Définition des curseurs
            def scanote1(self,xc):
                    do=int(xc)
                    xsi=self.sca[6].get()
                    xre=self.sca[1].get()
                    # Initialise sca[7](from_)
                    fromhu=-6-do
                    self.sca[7].configure(from_ = fromhu)
                    if do<xsi:self.sca[6].set(do)
                    if do>xre+1 :self.sca[1].set(do-1)
            # scanote1()
     
            def scanote2(self,xd):
                    re=int(xd)
                    xdo=self.sca[0].get()
                    xmi=self.sca[2].get()
                    if re<xdo-1:self.sca[0].set(re+1)
                    if re>xmi+1 :self.sca[2].set(re-1)
            # scanote2()
     
            def scanote3(self,xe):
                    mi=int(xe)
                    xre=self.sca[1].get()
                    xfa=self.sca[3].get()
                    if mi<xre-1:self.sca[1].set(mi+1)
                    if mi>xfa:self.sca[3].set(mi)
            # scanote3()
     
            def scanote4(self,xf):
                    fa=int(xf)
                    xmi=self.sca[2].get()
                    xsol=self.sca[4].get()
                    if fa<xmi:self.sca[2].set(fa)
                    if fa>xsol+1:self.sca[4].set(fa-1)
            # scanote4()
     
            def scanote5(self,xg):
                    sol=int(xg)
                    xfa=self.sca[3].get()
                    xla=self.sca[5].get()
                    if sol<xfa-1:self.sca[3].set(sol+1)
                    if sol>xla+1:self.sca[5].set(sol-1)
            # scanote5()
     
            def scanote6(self,xa):
                    la=int(xa)
                    xsol=self.sca[4].get()
                    xsi=self.sca[6].get()
                    if la<xsol-1:self.sca[4].set(la+1)
                    if la>xsi+1:self.sca[6].set(la-1)
            # scanote6()
     
            def scanote7(self,xb):
                    si=int(xb)
                    xla=self.sca[5].get()
                    xdo=self.sca[0].get()
                    # Initialise sca[7](to)
                    tohu=6-si
                    self.sca[7].configure(to = tohu)
                    if si<xla-1:self.sca[5].set(si+1)
                    if si>xdo:self.sca[0].set(si)
            # scanote7()
     
            def scanote8(self,xh):
                    sch=int(xh)
                    f_t=0                
                    xsi=self.sca[6].get()
                    tosi=t_si=self.sca[6].cget("to")
                    if (xsi+sch > t_si):f_t=-1                        
                    xdo=self.sca[0].get()
                    fromdo=f_do=self.sca[0].cget("from")
                    todo=t_do=self.sca[0].cget("to")
                    if (xdo+sch<f_do)or(f_t==-1):
                            fromdo = xdo+sch
                            todo = t_do+sch
                            f_t = -1                        
                    xre=self.sca[1].get()
                    fromre=f_re=self.sca[1].cget("from")
                    tore=t_re=self.sca[1].cget("to")
                    if f_t==-1:
                            fromre = f_re+sch
                            tore = t_re+sch                        
                    xmi=self.sca[2].get()
                    frommi=f_mi=self.sca[2].cget("from")
                    tomi=t_mi=self.sca[2].cget("to")
                    if f_t==-1:
                            frommi = f_mi+sch
                            tomi = t_mi+sch                        
                    xfa=self.sca[3].get()
                    fromfa=f_fa=self.sca[3].cget("from")
                    tofa=t_fa=self.sca[3].cget("to")
                    if f_t==-1:
                            fromfa = f_fa+sch
                            tofa = t_fa+sch                        
                    xsol=self.sca[4].get()
                    fromsol=f_sol=self.sca[4].cget("from")
                    tosol=t_sol=self.sca[4].cget("to")
                    if f_t==-1:
                            fromsol = f_sol+sch
                            tosol = t_sol+sch                        
                    xla=self.sca[5].get()
                    fromla=f_la=self.sca[5].cget("from")
                    tola=t_la=self.sca[5].cget("to")
                    if f_t==-1:
                            fromla = f_la+sch
                            tola = t_la+sch                        
                    xsi=self.sca[6].get()
                    fromsi=f_si=self.sca[6].cget("from")
                    tosi=t_si=self.sca[6].cget("to")
                    if (xsi+sch > t_si)or(f_t==-1):
                            fromsi = f_si+sch
                            tosi = t_si+sch
                            f_t=-1                        
                    self.sca[0].configure(from_ = fromdo, to = todo)
                    self.sca[0].set(xdo+sch)                
                    self.sca[1].configure(from_ = fromre, to = tore)
                    self.sca[1].set(xre+sch)                
                    self.sca[2].configure(from_ = frommi, to = tomi)
                    self.sca[2].set(xmi+sch)                
                    self.sca[3].configure(from_ = fromfa, to = tofa)
                    self.sca[3].set(xfa+sch)                
                    self.sca[4].configure(from_ = fromsol, to = tosol)
                    self.sca[4].set(xsol+sch)                
                    self.sca[5].configure(from_ = fromla, to = tola)
                    self.sca[5].set(xla+sch)                
                    self.sca[6].configure(from_ = fromsi, to = tosi)
                    self.sca[6].set(xsi+sch)
                    self.btgama.invoke()
            # scanote8()
     
            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 ='green')
                    self.can.create_line(10, 220, 740, 220, fill ='green')
                    fnotes=[0,-1,-2,-2,-3,-4,-5]
                    tnotes=[+5,+4,+3,+3,+2,+1,0]
                    self.sca[0].configure(from_ = fnotes[0], to = tnotes[0])
                    self.sca[0].set(0)
                    self.can.create_oval(300-5,220-5,300+5,220+5,fill='black')
                    self.sca[1].configure(from_ = fnotes[1], to = tnotes[1])
                    self.sca[1].set(0)
                    self.can.create_oval(320-5,220-5,320+5,220+5,fill='green')
                    self.sca[2].configure(from_ = fnotes[2], to = tnotes[2])
                    self.sca[2].set(0)
                    self.can.create_oval(340-5,220-5,340+5,220+5,fill='blue')
                    self.sca[3].configure(from_ = fnotes[3], to = tnotes[3])
                    self.sca[3].set(0)
                    self.can.create_oval(350-5,220-5,350+5,220+5,fill='grey')
                    self.sca[4].configure(from_ = fnotes[4], to = tnotes[4])
                    self.sca[4].set(0)
                    self.can.create_oval(370-5,220-5,370+5,220+5,fill='red')
                    self.sca[5].configure(from_ = fnotes[5], to = tnotes[5])
                    self.sca[5].set(0)
                    self.can.create_oval(390-5,220-5,390+5,220+5,fill='orange')
                    self.sca[6].configure(from_ = fnotes[6], to = tnotes[6])
                    self.sca[6].set(0)
                    self.can.create_oval(410-5,220-5,410+5,220+5,fill='yellow')
                    self.sca[7].set(0)
                    self.btgama.invoke()
            # zero()
     
            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(460, 450, 460, 110, fill ='green')
                    self.can.create_line(220, 220, 740, 220, fill ='green')
                    # De la table gammique aux tables diatoniques surnommées
                    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]]
                    gamnoms =['0','-2','+2','^2','-3','-23','-34x','+34','+23x','-34','x3','°3','+34x','°34x','^3',
                                      '-4','-24','^4','°4','-5','-25','-25+','+25-','-35','-35+','+45x','+25x','°35-','+35x',
                                      '-45+','-45','x5','x45+','-25°','-35°','-45°','°45-','°5','°35+','*5','°35x','-45x',
                                      '°45x','-6','+6','-26','-26+','+26-','+26','-36','-36+','-56','-56+','+56','x46+',
                                      '-26°','-46+','-46°','x36+','-56°','°46-','°36+','*6','°46+','°6','x26-']
     
                    # Récupération des notes cursives
                    ydo=self.sca[0].get()
                    xcpos_=300+100
                    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.sca[1].get()
                    xcpos_=320+100
                    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.sca[2].get()
                    xcpos_=340+100
                    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.sca[3].get()
                    xcpos_=350+100
                    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.sca[4].get()
                    xcpos_=370+100
                    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.sca[5].get()
                    xcpos_=390+100
                    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.sca[6].get()
                    xcpos_=410+100
                    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            
                    # while
                    diata[i]=5-cum_diat
     
                    # 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                   
                            # while
                            myx=myx2=0
                            for my in gammes:
                                    if diata2 == my:
                                            degre=x
                                            myx2=myx
                                            x=7
                                    # if
                                    myx+=1
                            # for
                            x+=1
                    # while
                    # 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
                            ynat+=1
                    # for
     
                    # Une tournée produit une tonalité modale de 7 notes
                    nat2=degre
                    deg = nom = 0
                    ynote = xgdeg = 30
                    ytone = 50
                    while deg < 7 :
                            nat = deg                          # Degré tonal en question
                            cri = gimj = gmod = maj = 0
                            xdeg = 60
                            text0 = gdeg[deg]
                            self.can.create_text(xgdeg,ynote+10,text=text0,
                                                                     font='bold',fill='black')
                            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 des notes
                                    gnt = gnat[nat2]        # Forme tonale (CDEFGAB)
                                    ideg = gdeg[deg]
                                    cri = cri + gimj        # Tonalité cumulée
                                    gimj = imaj - gmj   # Calcul tonal PAS/PAS
                                    cmod = gmod = cri
                                    if gmod > 0 :      # Forme altérative des tonalités
                                            imod = nordiese[cmod]
                                    if gmod < 0 :
                                            imod = subemol[cmod]
                                    if gmod == 0 :
                                            imod = subemol[cmod]
                                    gmod = gmod + cri   # Transition tonale
                                    # Construction du nom de la gamme
                                    if nom == 0 :
                                            ynom = ynt
                                            gnom = gnt
                                            tnom=ynom,gnom,gamnoms[myx2]
                                            self.can.create_text(xdeg+250,ynote,text=tnom,
                                                                                     font='bold',fill='black')
                                    # if
                                    nat+=1
                                    nat2+=1
                                    if nat > 6 :
                                            nat = 0
                                    if nat2 > 6 :
                                            nat2 = 0
                                    maj = maj + 1
                                    text1=[ynt,gnt]
                                    text2=[imod,maj]
                                    self.can.create_text(xdeg,ynote,text=text1)
                                    self.can.create_text(xdeg,ytone,text=text2,fill='blue')
                                    xdeg+=30
                                    nom=1
                            # while
                            ynote+=60
                            ytone+=60
                            nat2+=1
                            if nat2 > 6 :
                                    nat2 = 0
                            deg = deg + 1
                    # while
            # gamma()
    # class Gammique
     
    Gammique().mainloop()

  2. #2
    Expert éminent

    Homme Profil pro
    Inscrit en
    Octobre 2008
    Messages
    4 300
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations forums :
    Inscription : Octobre 2008
    Messages : 4 300
    Points : 6 780
    Points
    6 780
    Par défaut
    Salut,


    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
     
     
                    self.can
                    self.cad
                    self.btrad
                    self.btchr
                    self.bta13
                    self.rad
                    self.ent
                    self.sca
                    self.btzer
                    self.btgama 
                    self.btfictif
     
            def yoiioiioy(self):
     
            def yoi(self):
     
            def ioi(self):
     
            def ioy(self):
     
            def scanote1(self,xc):
     
            def scanote2(self,xd):
     
            def scanote3(self,xe):
     
            def zero(self):
     
            ...
    Une question me torture l'esprit, pourquoi fais-tu du Python ?

  3. #3
    Invité
    Invité(e)
    Par défaut
    Une question me torture l'esprit, pourquoi fais-tu du Python ?
    Je suis une personne qui fait de la programmation, parce qu'elle croit en ce qu'elle fait. Mon métier c'est l'ascenseur, et çà ne touche pas la programmation. La programmation est un supplément qui coûte assez cher, par rapport à mes finances. Python est gratuit, il est mis à jour, et j'ai l'internet. Je ne suis aucunement programmeur de métier, comme vous pouvez le voir. La passion qui m'entraine vers des merveilleux horizons, c'est la quantique musicale. Puis, comme je ne suis pas informé de ce qui existe en tant que le calcul des gammes musicales. Je ne sais pas si une application existe à ce niveau...
    Je suis venu ici pour satisfaire mon besoin d'expression publique et spécialisée, afin d'obtenir une aide auprès des professionnels expérimentés. Il n'y a pas de mal à çà, et en tant que débutant. Il se trouve que parfois, un bon tutoriel exposé (livre, ici,,,) et des conseils avisés, ne feront que de me rendre meilleur.
    Aussi, ce qui m'intéresse c'est de réaliser cette oeuvre. Car, il est toujours bien de pouvoir lire des gammes musicales intelligentes. Contrairement à ce que j'ai pu voir ailleurs, qui laissent entrevoir des gammes musicales douteuses.
    Comprenez bien, que même si ce contexte parait étrange. Il n'en est pas moins réel

    Mais au fait : Comment rendre un bouton invisible ?

    Puis, VinsS. Pourquoi cette question ??

  4. #4
    Expert éminent sénior
    Homme Profil pro
    Architecte technique retraité
    Inscrit en
    Juin 2008
    Messages
    21 287
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Manche (Basse Normandie)

    Informations professionnelles :
    Activité : Architecte technique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2008
    Messages : 21 287
    Points : 36 776
    Points
    36 776
    Par défaut
    Salut,

    Citation Envoyé par toumus Voir le message
    Mais au fait : Comment rendre un bouton invisible ?
    C'est .pack ou .grid ou... qui rendent un widget "visible".
    Ceci dit lorsqu'un bouton n'est pas "visible", l'utilisateur ne pouvant cliquer dessus, à quoi çà va bien pouvoir servir?

    - W
    Architectures post-modernes.
    Python sur DVP c'est aussi des FAQs, des cours et tutoriels

  5. #5
    Invité
    Invité(e)
    Par défaut
    C'est .pack ou .grid ou... qui rendent un widget "visible".
    Ceci dit lorsqu'un bouton n'est pas "visible", l'utilisateur ne pouvant cliquer dessus, à quoi çà va bien pouvoir servir?
    Voici le pourquoi : Au départ les boutons-radio appelaient une même (command) fonction, et j'espérais aussi récupérer la valeur du bouton sélectionné.
    Je n'ai pas réussi à faire ceci, alors j'ai fait cela... Maintenant, chaque bouton-radio a sa propre (command) fonction. Dans laquelle j'initialise une variable par le biais du widget "Entry", qui sert de mémoire tampon donnant l'état du niveau d'octave. Et ainsi, que chaque fonction appelle la même fonction par une invocation "invoke" du traitement relatif aux octaves...

    Je n'ai pas besoin de voir ce bouton contenant le traitement, sauf pour invoquer ce bouton. J'ai essayé d'invoquer la fonction directement, mais ce fut un échec.

    Résumé
    Les boutons-radio maintenant
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     # Groupe Octave RADIO
                    self.rad=[
                            Radiobutton(
                                    self.cad,
                                    variable=variable,
                                    text=text,
                                    value=value,
                                    command=command,
                            )for (variable, text, value,command) in (
                                    ("yioiy","Octave -1", "ioy",self.yoi),
                                    ("yioiy","Octave  0", "ioi",self.ioi),
                                    ("yioiy","Octave +1", "yoi",self.ioy),
    La mémoire tampon d'état du bouton-radio sélectionné
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    # Mémoire de forme d'octave
                    self.ent= Entry(self,bg='orange',font='bold')
                    self.ent.pack()
                    self.ent.delete(0,END)
                    self.ent.insert(END,"IOI")
    Les membres invocateurs à nu
    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
     # Les octaves du groupe RADIO
            def yoiioiioy(self):
                    xrad=self.ent.get()
            def yoi(self):
                    self.ent.delete(0,END)
                    self.ent.insert(END,"YOI")
                    self.btfictif.invoke()
            def ioi(self):
                    self.ent.delete(0,END)
                    self.ent.insert(END,"IOI")
                    self.btfictif.invoke()
            def ioy(self):
                    self.ent.delete(0,END)
                    self.ent.insert(END,"IOY")
                    self.btfictif.invoke()

  6. #6
    Expert éminent sénior
    Homme Profil pro
    Architecte technique retraité
    Inscrit en
    Juin 2008
    Messages
    21 287
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Manche (Basse Normandie)

    Informations professionnelles :
    Activité : Architecte technique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2008
    Messages : 21 287
    Points : 36 776
    Points
    36 776
    Par défaut
    Citation Envoyé par toumus Voir le message
    Voici le pourquoi : Au départ les boutons-radio appelaient une même (command) fonction, et j'espérais aussi récupérer la valeur du bouton sélectionné.
    Rien de très compliqué:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    import tkinter as tk
     
    def do_click(btn):
        print ('do_click:', btn.cget('text'))
     
    for x in range(5):
        btn = tk.Radiobutton(text='btn-%d' % x)
        btn['command'] = lambda btn=btn: do_click(btn)
        btn.pack()
     
    tk.mainloop()
    - W
    Architectures post-modernes.
    Python sur DVP c'est aussi des FAQs, des cours et tutoriels

  7. #7
    Invité
    Invité(e)
    Par défaut
    Rien de très compliqué:
    Là çà devient trop compliqué pour moi, je ne vais pas pouvoir modifier ce bout de code en fonction du besoin...
    Et en plus imaginez ce petit bout de code ultra configuré au milieu de mon code boréal exotique, (je rigole)

    Puis merci self.widget.pack_forget() la solution
    Sur le livre python en concentré
    Dernière modification par Invité ; 14/08/2015 à 21h20.

  8. #8
    Invité
    Invité(e)
    Par défaut
    Voilà çà marche, à l'ancienne

    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
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
     
    #!/usr/bin/env python 
    # -*- coding: utf-8 -*-
    # *
    # Application gammique évolutive
    # Version 1 : Calculer les gammes
    #
    from tkinter import *
    #import winsound
     
    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)
                    # Tracé d'encadrement
                    # Données de l'encadré : Axes(x,y)=365(x),220(y)
                    self.can.delete(ALL)
                    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')
     
                    # Fenêtre des utilités
                    self.cad=Frame(self,width=300,height=600)
                    self.cad.pack(side=LEFT)
                    # Bouton gamme_audio
                    #winsound.Beep(frequency, duration)
                    self.btrad=Button(self.cad,text ='Radio_inactive',width=15,bg='light blue')
                    self.btrad.pack()
                    # Bouton choix chromatique
                    self.btchr=Button(self.cad,text ='Chrome_inactif',width=15,bg='light blue')
                    self.btchr.pack()
                    # Bouton tableaux instruments
                    self.bttab=Button(self.cad,text ='Tabla_inactif',width=15,bg='light blue')
                    self.bttab.pack()
                    # Bouton accords1357
                    self.bta13=Button(self.cad,text ='A1357_inactif',width=15,bg='light blue')
                    self.bta13.pack()
     
                    # Mémoire de forme d'octave fantôme
                    self.ent= Entry(self)
                    self.ent.pack()
                    self.ent.pack_forget()          # Pantomime
                    self.ent.delete(0,END)
                    self.ent.insert(END,"IOI")
     
                    # Groupe Octave RADIO
                    self.rad=[
                            Radiobutton(
                                    self.cad,
                                    variable=variable,
                                    text=text,
                                    value=value,
                                    command=command,
                            )for (variable, text, value,command) in (
                                    ("yioiy","Octave +1", "ioy",self.ioy),
                                    ("yioiy","Octave  0", "ioi",self.ioi),
                                    ("yioiy","Octave -1", "yoi",self.yoi),
                            )
                    ]
                    for i in self.rad: i.pack()
                    self.rad[1].select()
     
                    # Les notes cursives scalpha : Graduations gérées.
                    self.sca=[
                            Scale(
                                    self,
                                    length=250,
                                    orient=HORIZONTAL,
                                    label=label,
                                    troughcolor=color,
                                    sliderlength=20,
                                    showvalue=1,
                                    from_=f,
                                    to=t,
                                    tickinterval=1,
                                    command=command,
                            ) for (label, color, f, t, command) in (
                                    ("C", "black", 0, 5, self.scanote1),
                                    ("D", "green", -1, 4, self.scanote2),
                                    ("E", "blue", -2, 3, self.scanote3),
                                    ("F", "grey", -2, 3, self.scanote4),
                                    ("G", "red", -3, 2, self.scanote5),
                                    ("A", "orange", -4, 1, self.scanote6),
                                    ("B", "yellow", -5, 0, self.scanote7),
                                    ("CDEFGAB", "ivory", -5, 5, self.scanote8),
                            )
                    ]
                    for x in self.sca: x.pack()
     
                    # Bouton gamme_naturelle
                    self.btzer=Button(self,text ='Zéro',width=25,command=self.zero)
                    self.btzer.pack()
                    # Bouton gamme_calculée
                    self.btgama=Button(self,text='gamme',width=25,command=self.gama)
                    self.btgama.pack()
                    # Bouton de relais fantôme 
                    self.btfictif=Button(self, command=self.yoiioiioy)
                    self.btfictif.pack()
                    self.btfictif.pack_forget()     # Pantomime
                    self.btfictif.invoke()
            # __init__()
     
            # Les octaves du groupe RADIO
            def yoiioiioy(self):
                    xrad=self.ent.get()
                    print ("Octave : ",xrad)
            def yoi(self):
                    self.ent.delete(0,END)
                    self.ent.insert(END,"YOI")
                    self.btfictif.invoke()
            def ioi(self):
                    self.ent.delete(0,END)
                    self.ent.insert(END,"IOI")
                    self.btfictif.invoke()
            def ioy(self):
                    self.ent.delete(0,END)
                    self.ent.insert(END,"IOY")
                    self.btfictif.invoke()
            # Définition des curseurs
            def scanote1(self,xc):
                    do=int(xc)
                    xsi=self.sca[6].get()
                    xre=self.sca[1].get()
                    # Initialise sca[7](from_)
                    fromhu=-6-do
                    self.sca[7].configure(from_ = fromhu)
                    if do<xsi:self.sca[6].set(do)
                    if do>xre+1 :self.sca[1].set(do-1)
            # scanote1()
     
            def scanote2(self,xd):
                    re=int(xd)
                    xdo=self.sca[0].get()
                    xmi=self.sca[2].get()
                    if re<xdo-1:self.sca[0].set(re+1)
                    if re>xmi+1 :self.sca[2].set(re-1)
            # scanote2()
     
            def scanote3(self,xe):
                    mi=int(xe)
                    xre=self.sca[1].get()
                    xfa=self.sca[3].get()
                    if mi<xre-1:self.sca[1].set(mi+1)
                    if mi>xfa:self.sca[3].set(mi)
            # scanote3()
     
            def scanote4(self,xf):
                    fa=int(xf)
                    xmi=self.sca[2].get()
                    xsol=self.sca[4].get()
                    if fa<xmi:self.sca[2].set(fa)
                    if fa>xsol+1:self.sca[4].set(fa-1)
            # scanote4()
     
            def scanote5(self,xg):
                    sol=int(xg)
                    xfa=self.sca[3].get()
                    xla=self.sca[5].get()
                    if sol<xfa-1:self.sca[3].set(sol+1)
                    if sol>xla+1:self.sca[5].set(sol-1)
            # scanote5()
     
            def scanote6(self,xa):
                    la=int(xa)
                    xsol=self.sca[4].get()
                    xsi=self.sca[6].get()
                    if la<xsol-1:self.sca[4].set(la+1)
                    if la>xsi+1:self.sca[6].set(la-1)
            # scanote6()
     
            def scanote7(self,xb):
                    si=int(xb)
                    xla=self.sca[5].get()
                    xdo=self.sca[0].get()
                    # Initialise sca[7](to)
                    tohu=6-si
                    self.sca[7].configure(to = tohu)
                    if si<xla-1:self.sca[5].set(si+1)
                    if si>xdo:self.sca[0].set(si)
            # scanote7()
     
            def scanote8(self,xh):
                    sch=int(xh)
                    f_t=0                
                    xsi=self.sca[6].get()
                    tosi=t_si=self.sca[6].cget("to")
                    if (xsi+sch > t_si):f_t=-1                        
                    xdo=self.sca[0].get()
                    fromdo=f_do=self.sca[0].cget("from")
                    todo=t_do=self.sca[0].cget("to")
                    if (xdo+sch<f_do)or(f_t==-1):
                            fromdo = xdo+sch
                            todo = t_do+sch
                            f_t = -1                        
                    xre=self.sca[1].get()
                    fromre=f_re=self.sca[1].cget("from")
                    tore=t_re=self.sca[1].cget("to")
                    if f_t==-1:
                            fromre = f_re+sch
                            tore = t_re+sch                        
                    xmi=self.sca[2].get()
                    frommi=f_mi=self.sca[2].cget("from")
                    tomi=t_mi=self.sca[2].cget("to")
                    if f_t==-1:
                            frommi = f_mi+sch
                            tomi = t_mi+sch                        
                    xfa=self.sca[3].get()
                    fromfa=f_fa=self.sca[3].cget("from")
                    tofa=t_fa=self.sca[3].cget("to")
                    if f_t==-1:
                            fromfa = f_fa+sch
                            tofa = t_fa+sch                        
                    xsol=self.sca[4].get()
                    fromsol=f_sol=self.sca[4].cget("from")
                    tosol=t_sol=self.sca[4].cget("to")
                    if f_t==-1:
                            fromsol = f_sol+sch
                            tosol = t_sol+sch                        
                    xla=self.sca[5].get()
                    fromla=f_la=self.sca[5].cget("from")
                    tola=t_la=self.sca[5].cget("to")
                    if f_t==-1:
                            fromla = f_la+sch
                            tola = t_la+sch                        
                    xsi=self.sca[6].get()
                    fromsi=f_si=self.sca[6].cget("from")
                    tosi=t_si=self.sca[6].cget("to")
                    if (xsi+sch > t_si)or(f_t==-1):
                            fromsi = f_si+sch
                            tosi = t_si+sch
                            f_t=-1                        
                    self.sca[0].configure(from_ = fromdo, to = todo)
                    self.sca[0].set(xdo+sch)                
                    self.sca[1].configure(from_ = fromre, to = tore)
                    self.sca[1].set(xre+sch)                
                    self.sca[2].configure(from_ = frommi, to = tomi)
                    self.sca[2].set(xmi+sch)                
                    self.sca[3].configure(from_ = fromfa, to = tofa)
                    self.sca[3].set(xfa+sch)                
                    self.sca[4].configure(from_ = fromsol, to = tosol)
                    self.sca[4].set(xsol+sch)                
                    self.sca[5].configure(from_ = fromla, to = tola)
                    self.sca[5].set(xla+sch)                
                    self.sca[6].configure(from_ = fromsi, to = tosi)
                    self.sca[6].set(xsi+sch)
                    self.btgama.invoke()
            # scanote8()
     
            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 ='green')
                    self.can.create_line(10, 220, 740, 220, fill ='green')
                    self.rad[1].invoke()    # Remise à l'octave zéro ou "ioi"
                    fnotes=[0,-1,-2,-2,-3,-4,-5]
                    tnotes=[+5,+4,+3,+3,+2,+1,0]
                    self.sca[0].configure(from_ = fnotes[0], to = tnotes[0])
                    self.sca[0].set(0)
                    self.can.create_oval(300-5,220-5,300+5,220+5,fill='black')
                    self.sca[1].configure(from_ = fnotes[1], to = tnotes[1])
                    self.sca[1].set(0)
                    self.can.create_oval(320-5,220-5,320+5,220+5,fill='green')
                    self.sca[2].configure(from_ = fnotes[2], to = tnotes[2])
                    self.sca[2].set(0)
                    self.can.create_oval(340-5,220-5,340+5,220+5,fill='blue')
                    self.sca[3].configure(from_ = fnotes[3], to = tnotes[3])
                    self.sca[3].set(0)
                    self.can.create_oval(350-5,220-5,350+5,220+5,fill='grey')
                    self.sca[4].configure(from_ = fnotes[4], to = tnotes[4])
                    self.sca[4].set(0)
                    self.can.create_oval(370-5,220-5,370+5,220+5,fill='red')
                    self.sca[5].configure(from_ = fnotes[5], to = tnotes[5])
                    self.sca[5].set(0)
                    self.can.create_oval(390-5,220-5,390+5,220+5,fill='orange')
                    self.sca[6].configure(from_ = fnotes[6], to = tnotes[6])
                    self.sca[6].set(0)
                    self.can.create_oval(410-5,220-5,410+5,220+5,fill='yellow')
                    self.sca[7].set(0)
                    self.btgama.invoke()
            # zero()
     
            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(460, 450, 460, 110, fill ='green')
                    self.can.create_line(220, 220, 740, 220, fill ='green')
                    # De la table gammique aux tables diatoniques surnommées
                    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]]
                    gamnoms =['0','-2','+2','^2','-3','-23','-34x','+34','+23x','-34','x3','°3','+34x','°34x','^3',
                                      '-4','-24','^4','°4','-5','-25','-25+','+25-','-35','-35+','+45x','+25x','°35-','+35x',
                                      '-45+','-45','x5','x45+','-25°','-35°','-45°','°45-','°5','°35+','*5','°35x','-45x',
                                      '°45x','-6','+6','-26','-26+','+26-','+26','-36','-36+','-56','-56+','+56','x46+',
                                      '-26°','-46+','-46°','x36+','-56°','°46-','°36+','*6','°46+','°6','x26-']
     
                    # Récupération des notes cursives
                    ydo=self.sca[0].get()
                    xcpos_=300+100
                    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.sca[1].get()
                    xcpos_=320+100
                    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.sca[2].get()
                    xcpos_=340+100
                    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.sca[3].get()
                    xcpos_=350+100
                    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.sca[4].get()
                    xcpos_=370+100
                    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.sca[5].get()
                    xcpos_=390+100
                    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.sca[6].get()
                    xcpos_=410+100
                    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            
                    # while
                    diata[i]=5-cum_diat
     
                    # 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                   
                            # while
                            myx=myx2=0
                            for my in gammes:
                                    if diata2 == my:
                                            degre=x
                                            myx2=myx
                                            x=7
                                    # if
                                    myx+=1
                            # for
                            x+=1
                    # while
                    # 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
                            ynat+=1
                    # for
     
                    # Une tournée produit une tonalité modale de 7 notes
                    nat2=degre
                    deg = nom = 0
                    ynote = xgdeg = 30
                    ytone = 50
                    while deg < 7 :
                            nat = deg                          # Degré tonal en question
                            cri = gimj = gmod = maj = 0
                            xdeg = 60
                            text0 = gdeg[deg]
                            self.can.create_text(xgdeg,ynote+10,text=text0,
                                                                     font='bold',fill='black')
                            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 des notes
                                    gnt = gnat[nat2]        # Forme tonale (CDEFGAB)
                                    ideg = gdeg[deg]
                                    cri = cri + gimj        # Tonalité cumulée
                                    gimj = imaj - gmj   # Calcul tonal PAS/PAS
                                    cmod = gmod = cri
                                    if gmod > 0 :      # Forme altérative des tonalités
                                            imod = nordiese[cmod]
                                    if gmod < 0 :
                                            imod = subemol[cmod]
                                    if gmod == 0 :
                                            imod = subemol[cmod]
                                    gmod = gmod + cri   # Transition tonale
                                    # Construction du nom de la gamme
                                    if nom == 0 :
                                            ynom = ynt
                                            gnom = gnt
                                            tnom=ynom,gnom,gamnoms[myx2]
                                            self.can.create_text(xdeg+250,ynote,text=tnom,
                                                                                     font='bold',fill='black')
                                    # if
                                    nat+=1
                                    nat2+=1
                                    if nat > 6 :
                                            nat = 0
                                    if nat2 > 6 :
                                            nat2 = 0
                                    maj = maj + 1
                                    text1=[ynt,gnt]
                                    text2=[imod,maj]
                                    self.can.create_text(xdeg,ynote,text=text1)
                                    self.can.create_text(xdeg,ytone,text=text2,fill='blue')
                                    xdeg+=30
                                    nom=1
                            # while
                            ynote+=60
                            ytone+=60
                            nat2+=1
                            if nat2 > 6 :
                                    nat2 = 0
                            deg = deg + 1
                    # while
            # gamma()
    # class Gammique
     
    Gammique().mainloop()

Discussions similaires

  1. bouton invisible par programmation
    Par t.n.b.g dans le forum WinDev
    Réponses: 1
    Dernier message: 25/06/2008, 14h58
  2. Rendre bouton invisible
    Par maysa dans le forum Général JavaScript
    Réponses: 29
    Dernier message: 27/06/2007, 12h38
  3. Réponses: 3
    Dernier message: 11/04/2007, 13h18
  4. bouton invisible
    Par franfr57 dans le forum Général JavaScript
    Réponses: 9
    Dernier message: 03/05/2006, 11h51
  5. [Windows 32] Bouton invisible
    Par Trap D dans le forum MFC
    Réponses: 3
    Dernier message: 31/05/2005, 19h10

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo