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

Python Discussion :

Petit Problème sur mon Gros code


Sujet :

Python

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Octobre 2022
    Messages
    20
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 31
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Octobre 2022
    Messages : 20
    Par défaut Petit Problème sur mon Gros code
    bonjour a tous

    je suis nouveau sur python et tkinter

    dans mon code j'allume des machine ou je les étain en fonction d'un certain voltage

    j'aimerais que le programme attend 15 minutes quand il a allumer une machine mais que si les volte descend en dessous de 49voltes dans se temps d'attente j'aimerais qui coupe la dernière machine
    malheureusement je n'arrive pas a couper le temps d'attente

    je sait qu'il existe .after_cancel mais je n'arrive pas a le faire fonctionner

    voici mon code (attention les yeux je suis débutant

    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
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    from threading import Timer
    import time
    from selenium import webdriver 
    import datetime
    from tkinter import *
    from Action import *
    import os, sys
    from yocto_api import *
    from yocto_voltage import *
     
     
     
     
    root = Tk() 
    root.config(bg='#41B77F')
    #width = root.winfo_screenwidth()
    #height = root.winfo_screenheight()
    #root.geometry("%dx%d" % (width, height))
    root.geometry('550x300+810+550')
    root.bouton_flag = False
     
    #AttentePlus6 = 8000# 8 SECONDE
    #AttenteAllume = 8000# 8 SECONDE
    #AttenteEtein = 20000# 8 SECONDE
    #AttenteMoins1 = 8000# 8 SECONDE
     
    AttentePlus6 = 20000# 2 MINUTES
    AttenteAllume = 900000# 15 MINUTES
    AttenteEtein = 600000# 10 MINUTES
    AttenteMoins1 = 120000# 2 MINUTES
     
    def voltage45():
        if btnVolt["bg"]=="white":
            btnVolt["bg"]="red" 
        else:
            btnVolt["bg"]="white"
     
    btnVolt = Button(root, height=1, width=10, text="CheckVolt", command=voltage45, bg="white")
    btnVolt.place(relx=0.15, rely=0.73)
     
    volt = 0.0
     
    def voltage():
        errmsg=YRefParam()
        YAPI.RegisterHub("usb",errmsg)
        voltage = YVoltage.FindVoltage("VOLTAGE1-224133.voltage1")
        if voltage.isOnline():
            global volt
            volt = voltage.get_currentValue()
            #print("Volt : ",volt)
            #if btnVolt["bg"]=="white":
            #    volt == 45
        else:
            if btnVolt["bg"]=="white":
                volt = 55
            else:
                volt=45
            #print("Pas de module Volt : 55")
     
    def b1():
        global state
        if state == 0:
            state = 1
        elif state == 1:
            state = 0
        #print("state : ",state)
        a1()
     
    def a1():
        global state
        if state == 1:
            machine1Carte2["bg"]="red"
            if reel["bg"] == "red":
                print("allumer machine 1 REEL")
                #print(state)
                M1C2()
            else:
                print("allumer machine 1 SIMU")
        elif state == 0:
            machine1Carte2["bg"]="white"
            if reel["bg"] == "red":
                print("eteindre machine 1 REEL")
                #print(state)
                M1C2()
            else:
                print("eteindre machine 1 SIMU")
     
        return "machine 1"
     
    def b2():
        global state
        if state == 1:
            state = 2
        elif state == 2:
            state = 1
        #print("state : ",state)
        a2()
     
    def a2():
        global state
        if state == 2:
            machine1Carte3["bg"]="red"
            if reel["bg"] == "red":
                print("allumer machine 2 REEL")
                #print(state)
                M1C3()
            else:
                print("allumer machine 2 SIMU")
        elif state == 1:
            machine1Carte3["bg"]="white"
            if reel["bg"] == "red":
                print("eteindre machine 2 REEL")
                #print(state)
                M1C3()
            else:
                print("eteindre machine 2 SIMU")
        return "machine2"
     
    def b3():
        global state
        if state == 2:
            state = 3
        elif state == 3:
            state = 2
        #print("state : ",state)
        a3()
     
    def a3():
        global state
        if state == 3:
            machine2Carte1["bg"]="red"
            if reel["bg"] == "red":
                print("allumer machine 3 REEL")
                #print(state)
                M2C1()
            else:
                print("allumer machine 3 SIMU")
        elif state == 2:
            machine2Carte1["bg"]="white"
            if reel["bg"] == "red":
                print("eteindre machine 3 REEL")
                #print(state)
                M2C1()
            else:
                print("eteindre machine 3 SIMU")
        return "machine3"
     
    def b4():
        global state
        if state == 3:
            state = 4
        elif state == 4:
            state = 3
        #print("state : ",state)
        a4()
     
    def a4():
        global state
        if state == 4:
            machine2Carte2["bg"]="red"
            if reel["bg"] == "red":
                print("allumer machine 4 REEL")
                #print(state)
                M2C2()
            else:
                print("allumer machine 4 SIMU")
        elif state == 3:
            machine2Carte2["bg"]="white"
            if reel["bg"] == "red":
                print("eteindre machine 4 REEL")
                #print(state)
                M2C2()
            else:
                print("eteindre machine 4 SIMU")
        return "machine4"
    def b5():
        global state
        if state == 4:
            state = 5
        elif state == 5:
            state = 4
        #print("state : ",state)
        a5()
     
    def a5():
        global state
        if state == 5:
            machine2Carte3["bg"]="red"
            if reel["bg"] == "red":
                print("allumer machine 5 REEL")
                #print(state)
                M2C3()
            else:
                print("allumer machine 5 SIMU")
        elif state == 4:
            machine2Carte3["bg"]="white"
            if reel["bg"] == "red":
                print("eteindre machine 5 REEL")
                #print(state)
                M2C3()
            else:
                print("eteindre machine 5 SIMU")
        return "machine5"
     
    def b6():
        global state
        if state == 5:
            state = 6
        elif state == 6:
            state = 5
        #print("state : ",state)
        a6()
     
    def a6():
        global state
        if state == 6:
            machine3Carte1["bg"]="red"
            if reel["bg"] == "red":
                print("allumer machine 6 REEL")
                #print(state)
                M3C1()
            else:
                print("allumer machine 6 SIMU")
        elif state == 5:
            machine3Carte1["bg"]="white"
            if reel["bg"] == "red":
                print("eteindre machine 6 REEL")
                #print(state)
                M3C1()
            else:
                print("eteindre machine 6 SIMU")
        return "machine6"
     
    def b7():
        global state
        if state == 6:
            state = 7
        elif state == 7:
            state = 6
        #print("state : ",state)
        a7()
     
    def a7():
        global state
        if state == 7:
            machine3Carte2["bg"]="red"
            if reel["bg"] == "red":
                print("allumer machine 7 REEL")
                #print(state)
                M3C2()
            else:
                print("allumer machine 7 SIMU")
        elif state == 6:
            machine3Carte2["bg"]="white"
            if reel["bg"] == "red":
                print("eteindre machine 7 REEL")
                #print(state)
                M3C2()
            else:
                print("eteindre machine 7 SIMU")
        return "machine7"
     
    def b8():
        global state
        if state == 7:
            state = 8
        elif state == 8:
            state = 7
        #print("state : ",state)
        a8()
     
    def a8():
        global state
        if state == 8:
            machine3Carte3["bg"]="red"
            if reel["bg"] == "red":
                print("allumer machine 8 REEL")
                #print(state)
                M3C3()
            else:
                print("allumer machine 8 SIMU")
        elif state == 7:
            machine3Carte3["bg"]="white"
            if reel["bg"] == "red":
                print("eteindre machine 8 REEL")
                #print(state)
                M3C3()
            else:
                print("eteindre machine 8 SIMU")
        return "machine8"
     
    pool=(a1, a2, a3, a4, a5, a6, a7, a8)
    state=0
     
    #etap = 0
     
     
    #if volt < 49 and ?:
    #    root.after_cancel(root)
     
     
    #AttenteAllume = 4000# 2 MINUTES
    #AttenteEtein = 4000# 5 MINUTES
    #AttenteMoins1 = 4000# 2 MINUTES
     
    test = 0
    timerun = 0
    etap = 0
     
     
     
     
    def do():
        if auto["bg"] == "white":
            auto["bg"] = "red"
        root.bouton_flag = True if root.bouton_flag == False else False
        #root.after(600000, do)
        def callback():
            currentTimeDate = datetime.datetime.now()
            currentTime = currentTimeDate.strftime('%H:%M:%S')
            global indexcoupure
            global state
            global pool
            global etap
            global timerun
            global test
            voltage()
            global volt
            #volt = 55
            if volt > 53.5 and volt <= 55 and root.bouton_flag:
                voltage()
                if reel["bg"] == "red":
                    print("1ER check attendre 5 seconde")
                    print(volt," V")
                    time.sleep(5)
                if volt > 53.5 and volt <= 55 and root.bouton_flag:
                    if reel["bg"] == "red":
                        print("2eme check attendre 5 seconde")
                        voltage()
                        print(volt," V")
                        time.sleep(5)
                    if volt > 53.5 and volt <= 55 and root.bouton_flag:
                        if reel["bg"] == "red":
                            print("3eme check attendre 5 seconde")
                            voltage()
                            print(volt," V")
                            time.sleep(5)  
                        if volt > 53.5 and volt <= 55 and root.bouton_flag:
                            print("3eme check GO")
                            if state >= len(pool):
                                print("(%d) - Impossible, plus de machine à allumer" % state)
                                #print("State = ", state)
                                etap = 1
                            else:
                                state+=1
                                print("(%d) - Allumage %s" % (state, pool[state-1]()))
                                #(state, pool[state-1]())
                                #print("State = ", state)
                                etap = 2
     
     
     
     
            elif volt < 49:
                if state <= 0:
                    print("(%d) - Impossible, plus de machine à éteindre" % state)
                    print("State = ", state)
                    etap = 3
                else:
                    state-=1
                    #print("(%d) - Extinction %s" % (state, pool[state-1]()))
                    print("(%d) - Extinction %s" % (state, pool[state]()))
                    #(state, pool[state-1]())
                    etap = 4
                    #print("State = ", state)
     
     
            else:
                print("(%d) - Rien à faire..." % state) 
                #print("State = ", state)
     
     
     
            #if root.bouton_flag:
            if etap == 0:
                print("Entre 49 et 55 Attendre 10 seconde")
                print(currentTime)
                root.after(10000, callback)
                timerun = 10
            if etap == 1:
                print("attendre 2 minutes")
                print(currentTime)
                root.after(AttentePlus6, callback)
                timerun = 120
            if etap == 2:  
                print("attendre 15 minutes")
                print(currentTime)
                indexcoupure = 1
                root.after(AttenteAllume, callback)  
                timerun = 600
     
            if etap == 3:
                print("attendre 2 minutes")
                print(currentTime)
                root.after(AttenteMoins1, callback)
                timerun = 120
            if etap == 4:
                print("attendre 10 minutes")
                print(currentTime)
                root.after(AttenteEtein, callback)
                timerun = 300
            if timerun>0:
                test = 1
                #tick()
                pass
        root.after(600000, root)
        callback()
     
    def prece():
        global state
        if volt<49:
            if state <= 0:
                print("(%d) - Impossible, plus de machine à éteindre" % state)
            else:
                state-=1
                print("(%d) - Extinction %s" % (state, pool[state]()))
                (state, pool[state-1]())
                root.after(100000, root)
     
    def suiv():
        global state
        if state >= len(pool):
            print("(%d) - Impossible, plus de machine à allumer" % state)
            print("State = ", state)
            if root.bouton_flag:
                print("attendre 2 minutes")
        else:
            state+=1
            print("(%d) - Allumage %s" % (state, pool[state-1]()))
            (state, pool[state-1]())
            print("State = ", state)
            if root.bouton_flag:
                print("attendre 15 minutes")
     
    def Reel():
        if reel["bg"] == "white":
            reel["bg"] = "red"
            print("Passer en mode REEL")
        else :
            reel["bg"] = "white"
            print("Passer en mode SIMU")
     
    def clock():
        hour = time.strftime("%H")
        minute = time.strftime("%M")
        seconde = time.strftime("%S")
     
        my_label.config(text=hour + ":" + minute + ":" + seconde)
        my_label.after(1000, clock)
     
    #def update():
    #    my_label.config(text="new text")
     
    my_label = Label(root, text="", font=("Helvetica", 48), fg="green", bg="black")
    my_label.place(relx=0.5, rely=0.1, anchor=CENTER)
     
    clock()
     
    voltage()
     
     
    def afficherVolt():
        voltage()
        global couleur
        global etap
        if volt < 49:
            couleur = "red"
            if etap == 2:
                do()
        elif volt > 54:
            couleur = "orange"
        elif volt > 49 and volt< 54:
            couleur = "green"
        else:
            couleur = "orange"
        voltok.config(text=volt, fg=couleur)
        root.after(1000, afficherVolt)
     
     
     
     
     
     
     
     
    etap = 0
     
    def update():
     
        voltok.config(text="new text")
        my_label.config(text="new text")
     
     
     
    voltok = Label(root, text="", font=("Helvetica", 35), fg="orange", bg="black")
    voltok.place(relx=0.5, rely=0.8, anchor=CENTER)
     
    afficherVolt()
     
     
    def tick():
        global timerun
        timerun-=1
        timer['text'] = timerun
        timer.after(1000, tick)
     
     
    timer = Label(root, fg='orange')
    timer.place(relx=0.7, rely=0.8, anchor=CENTER)
     
     
     
     
     
     
    reel = Button(root, text = 'REEL', command=Reel, bg="white")
    reel.place(relx=0.1, rely=0.1, anchor=CENTER)
     
    machine1Carte2 = Button(root, text = 'Machine 1 Carte 2', command = b1, bg="white")
    machine1Carte2.place(relx=0.2, rely=0.4, anchor=CENTER)
     
    machine1Carte3 = Button(root, text = 'Machine 1 Carte 3', command = b2, bg="white")
    machine1Carte3.place(relx=0.2, rely=0.5, anchor=CENTER)
     
    machine2Carte1 = Button(root, text = 'Machine 2 Carte 1', command = b3, bg="white")
    machine2Carte1.place(relx=0.5, rely=0.3, anchor=CENTER)
     
    machine2Carte2 = Button(root, text = 'Machine 2 Carte 2', command = b4, bg="white")
    machine2Carte2.place(relx=0.5, rely=0.4, anchor=CENTER)
     
    machine2Carte3 = Button(root, text = 'Machine 2 Carte 3', command = b5, bg="white")
    machine2Carte3.place(relx=0.5, rely=0.5, anchor=CENTER)
     
    machine3Carte1 = Button(root, text = 'Machine 3 Carte 1', command = b6, bg="white")
    machine3Carte1.place(relx=0.8, rely=0.3, anchor=CENTER)
     
    machine3Carte2 = Button(root, text = 'Machine 3 Carte 2', command = b6, bg="white")
    machine3Carte2.place(relx=0.8, rely=0.4, anchor=CENTER)
     
    machine3Carte3 = Button(root, text = 'Machine 3 Carte 3', command = b6, bg="white")
    machine3Carte3.place(relx=0.8, rely=0.5, anchor=CENTER)
     
    precedent = Button(root, text = '<<<<', command = prece, bg="white")
    precedent.place(relx=0.2, rely=0.6, anchor=CENTER)
     
    suivant = Button(root, text = '>>>>', command = suiv, bg="white")
    suivant.place(relx=0.8, rely=0.6, anchor=CENTER)
     
    auto = Button(root, text="Automatique", bg="white", command=do)
    auto.place(relx=0.5, rely=0.6, anchor=CENTER)
     
     
     
    root.mainloop()
    merci d'avance pour votre aide et désoler pour les faute d'orthographe

    J'ai fait un petit condensé pour éviter de se fatiguer
    vous avez juste a cliquer sur CheckVolt pour changer pour passez en dessous de 49

    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
    from threading import Timer
    import time
    from selenium import webdriver 
    import datetime
    from tkinter import *
    import os, sys
     
     
     
     
     
    root = Tk() 
    root.config(bg='#41B77F')
    root.geometry('550x300+810+550')
    root.bouton_flag = False
     
    AttentePlus6 = 10000# 10 SECONDE
    AttenteAllume = 10000# 10 SECONDE
    AttenteEtein = 10000# 10 SECONDE
    AttenteMoins1 = 10000# 10 SECONDE
     
    def voltage45():
        if btnVolt["bg"]=="white":
            btnVolt["bg"]="red" 
        else:
            btnVolt["bg"]="white"
     
    btnVolt = Button(root, height=1, width=10, text="CheckVolt", command=voltage45, bg="white")
    btnVolt.place(relx=0.15, rely=0.73)
     
    volt = 0.0
     
    def voltage():
        global volt
        if btnVolt["bg"]=="white":
            volt = 55
        else:
            volt=45
     
    def b1():
        global state
        if state == 0:
            state = 1
        elif state == 1:
            state = 0
        a1()
     
    def a1():
        global state
        if state == 1:
            machine1Carte2["bg"]="red"
            if reel["bg"] == "red":
                print("allumer machine 1 REEL")
            else:
                print("allumer machine 1 SIMU")
        elif state == 0:
            machine1Carte2["bg"]="white"
            if reel["bg"] == "red":
                print("eteindre machine 1 REEL")
            else:
                print("eteindre machine 1 SIMU")
     
        return "machine 1"
     
    def b2():
        global state
        if state == 1:
            state = 2
        elif state == 2:
            state = 1
        a2()
     
    def a2():
        global state
        if state == 2:
            machine1Carte3["bg"]="red"
            if reel["bg"] == "red":
                print("allumer machine 2 REEL")
            else:
                print("allumer machine 2 SIMU")
        elif state == 1:
            machine1Carte3["bg"]="white"
            if reel["bg"] == "red":
                print("eteindre machine 2 REEL")
            else:
                print("eteindre machine 2 SIMU")
        return "machine2"
     
    def b3():
        global state
        if state == 2:
            state = 3
        elif state == 3:
            state = 2
        a3()
     
    def a3():
        global state
        if state == 3:
            machine2Carte1["bg"]="red"
            if reel["bg"] == "red":
                print("allumer machine 3 REEL")
            else:
                print("allumer machine 3 SIMU")
        elif state == 2:
            machine2Carte1["bg"]="white"
            if reel["bg"] == "red":
                print("eteindre machine 3 REEL")
            else:
                print("eteindre machine 3 SIMU")
        return "machine3"
     
    def b4():
        global state
        if state == 3:
            state = 4
        elif state == 4:
            state = 3
        a4()
     
    def a4():
        global state
        if state == 4:
            machine2Carte2["bg"]="red"
            if reel["bg"] == "red":
                print("allumer machine 4 REEL")
            else:
                print("allumer machine 4 SIMU")
        elif state == 3:
            machine2Carte2["bg"]="white"
            if reel["bg"] == "red":
                print("eteindre machine 4 REEL")
            else:
                print("eteindre machine 4 SIMU")
        return "machine4"
    def b5():
        global state
        if state == 4:
            state = 5
        elif state == 5:
            state = 4
        a5()
     
    def a5():
        global state
        if state == 5:
            machine2Carte3["bg"]="red"
            if reel["bg"] == "red":
                print("allumer machine 5 REEL")
            else:
                print("allumer machine 5 SIMU")
        elif state == 4:
            machine2Carte3["bg"]="white"
            if reel["bg"] == "red":
                print("eteindre machine 5 REEL")
            else:
                print("eteindre machine 5 SIMU")
        return "machine5"
     
    def b6():
        global state
        if state == 5:
            state = 6
        elif state == 6:
            state = 5
        a6()
     
    def a6():
        global state
        if state == 6:
            machine3Carte1["bg"]="red"
            if reel["bg"] == "red":
                print("allumer machine 6 REEL")
            else:
                print("allumer machine 6 SIMU")
        elif state == 5:
            machine3Carte1["bg"]="white"
            if reel["bg"] == "red":
                print("eteindre machine 6 REEL")
            else:
                print("eteindre machine 6 SIMU")
        return "machine6"
     
    def b7():
        global state
        if state == 6:
            state = 7
        elif state == 7:
            state = 6
        a7()
     
    def a7():
        global state
        if state == 7:
            machine3Carte2["bg"]="red"
            if reel["bg"] == "red":
                print("allumer machine 7 REEL")
            else:
                print("allumer machine 7 SIMU")
        elif state == 6:
            machine3Carte2["bg"]="white"
            if reel["bg"] == "red":
                print("eteindre machine 7 REEL")
            else:
                print("eteindre machine 7 SIMU")
        return "machine7"
     
    def b8():
        global state
        if state == 7:
            state = 8
        elif state == 8:
            state = 7
        #print("state : ",state)
        a8()
     
    def a8():
        global state
        if state == 8:
            machine3Carte3["bg"]="red"
            if reel["bg"] == "red":
                print("allumer machine 8 REEL")
            else:
                print("allumer machine 8 SIMU")
        elif state == 7:
            machine3Carte3["bg"]="white"
            if reel["bg"] == "red":
                print("eteindre machine 8 REEL")
            else:
                print("eteindre machine 8 SIMU")
        return "machine8"
     
    pool=(a1, a2, a3, a4, a5, a6, a7, a8)
    state=0
    etap = 0
     
    def do():
        if auto["bg"] == "white":
            auto["bg"] = "red"
        root.bouton_flag = True if root.bouton_flag == False else False
        def callback():
            currentTimeDate = datetime.datetime.now()
            currentTime = currentTimeDate.strftime('%H:%M:%S')
            global state
            global pool
            global etap
            voltage()
            global volt
            #volt = 55
            if volt > 53.5 and volt <= 55 and root.bouton_flag:
                voltage()
                if reel["bg"] == "red":
                    print("1ER check attendre 5 seconde")
                    print(volt," V")
                if volt > 53.5 and volt <= 55 and root.bouton_flag:
                    if reel["bg"] == "red":
                        print("2eme check attendre 5 seconde")
                        voltage()
                        print(volt," V")
                    if volt > 53.5 and volt <= 55 and root.bouton_flag:
                        if reel["bg"] == "red":
                            print("3eme check attendre 5 seconde")
                            voltage()
                            print(volt," V") 
                        if volt > 53.5 and volt <= 55 and root.bouton_flag:
                            print("3eme check GO")
                            if state >= len(pool):
                                print("(%d) - Impossible, plus de machine à allumer" % state)
                                #print("State = ", state)
                                etap = 1
                            else:
                                state+=1
                                print("(%d) - Allumage %s" % (state, pool[state-1]()))
                                #(state, pool[state-1]())
                                #print("State = ", state)
                                etap = 2
     
     
     
     
            elif volt < 49:
                if state <= 0:
                    print("(%d) - Impossible, plus de machine à éteindre" % state)
                    print("State = ", state)
                    etap = 3
                else:
                    state-=1
                    #print("(%d) - Extinction %s" % (state, pool[state-1]()))
                    print("(%d) - Extinction %s" % (state, pool[state]()))
                    #(state, pool[state-1]())
                    etap = 4
                    #print("State = ", state)
     
     
            else:
                print("(%d) - Rien à faire..." % state) 
                #print("State = ", state)
     
            if etap == 0:
                print("Entre 49 et 55 Attendre 10 seconde")
                print(currentTime)
                root.after(10000, callback)
            if etap == 1:
                print("attendre 2 minutes")
                print(currentTime)
                root.after(AttentePlus6, callback)
            if etap == 2:  
                print("attendre 15 minutes")
                print(currentTime)
                root.after(AttenteAllume, callback)  
     
            if etap == 3:
                print("attendre 2 minutes")
                print(currentTime)
                root.after(AttenteMoins1, callback)
            if etap == 4:
                print("attendre 10 minutes")
                print(currentTime)
                root.after(AttenteEtein, callback)
        callback()
     
    def Reel():
        if reel["bg"] == "white":
            reel["bg"] = "red"
            print("Passer en mode REEL")
        else :
            reel["bg"] = "white"
            print("Passer en mode SIMU")
     
    def clock():
        hour = time.strftime("%H")
        minute = time.strftime("%M")
        seconde = time.strftime("%S")
     
        my_label.config(text=hour + ":" + minute + ":" + seconde)
        my_label.after(1000, clock)
     
    my_label = Label(root, text="", font=("Helvetica", 48), fg="green", bg="black")
    my_label.place(relx=0.5, rely=0.1, anchor=CENTER)
     
    clock()
     
    voltage()
     
     
    def afficherVolt():
        voltage()
        global couleur
        global etap
        if volt < 49:
            couleur = "red"
        elif volt > 54:
            couleur = "orange"
        elif volt > 49 and volt< 54:
            couleur = "green"
        else:
            couleur = "orange"
        voltok.config(text=volt, fg=couleur)
        root.after(1000, afficherVolt)
     
    def update():
     
        voltok.config(text="new text")
        my_label.config(text="new text")
     
     
     
    voltok = Label(root, text="", font=("Helvetica", 35), fg="orange", bg="black")
    voltok.place(relx=0.5, rely=0.8, anchor=CENTER)
     
    afficherVolt()
     
     
    timer = Label(root, fg='orange')
    timer.place(relx=0.7, rely=0.8, anchor=CENTER)
     
     
     
     
     
     
    reel = Button(root, text = 'REEL', command=Reel, bg="white")
    reel.place(relx=0.1, rely=0.1, anchor=CENTER)
     
    machine1Carte2 = Button(root, text = 'Machine 1 Carte 2', command = b1, bg="white")
    machine1Carte2.place(relx=0.2, rely=0.4, anchor=CENTER)
     
    machine1Carte3 = Button(root, text = 'Machine 1 Carte 3', command = b2, bg="white")
    machine1Carte3.place(relx=0.2, rely=0.5, anchor=CENTER)
     
    machine2Carte1 = Button(root, text = 'Machine 2 Carte 1', command = b3, bg="white")
    machine2Carte1.place(relx=0.5, rely=0.3, anchor=CENTER)
     
    machine2Carte2 = Button(root, text = 'Machine 2 Carte 2', command = b4, bg="white")
    machine2Carte2.place(relx=0.5, rely=0.4, anchor=CENTER)
     
    machine2Carte3 = Button(root, text = 'Machine 2 Carte 3', command = b5, bg="white")
    machine2Carte3.place(relx=0.5, rely=0.5, anchor=CENTER)
     
    machine3Carte1 = Button(root, text = 'Machine 3 Carte 1', command = b6, bg="white")
    machine3Carte1.place(relx=0.8, rely=0.3, anchor=CENTER)
     
    machine3Carte2 = Button(root, text = 'Machine 3 Carte 2', command = b6, bg="white")
    machine3Carte2.place(relx=0.8, rely=0.4, anchor=CENTER)
     
    machine3Carte3 = Button(root, text = 'Machine 3 Carte 3', command = b6, bg="white")
    machine3Carte3.place(relx=0.8, rely=0.5, anchor=CENTER)
     
    auto = Button(root, text="Automatique", bg="white", command=do)
    auto.place(relx=0.5, rely=0.6, anchor=CENTER)
     
    root.mainloop()

  2. #2
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Octobre 2022
    Messages
    20
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 31
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Octobre 2022
    Messages : 20
    Par défaut
    Désoler pour le dérangement je croit avoir trouver ma solution

    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
    from threading import Timer
    import time
    from selenium import webdriver 
    import datetime
    from tkinter import *
    from Action import *
    import os, sys
    from yocto_api import *
    from yocto_voltage import *
     
     
     
    root = Tk() 
    root.config(bg='#41B77F')
    root.geometry('550x300+810+550')
    root.bouton_flag = False
     
    #AttentePlus6 = 10000# 10 SECONDE
    #AttenteAllume = 10000# 10 SECONDE
    #AttenteEtein = 10000# 10 SECONDE
    #AttenteMoins1 = 100000# 10 SECONDE
     
     
    AttentePlus6 = 20000# 2 MINUTES
    AttenteAllume = 900000# 15 MINUTES
    AttenteEtein = 420000# 7 MINUTES
    AttenteMoins1 = 120000# 2 MINUTES
     
    def voltage():
        errmsg=YRefParam()
        YAPI.RegisterHub("usb",errmsg)
        voltage = YVoltage.FindVoltage("VOLTAGE1-224133.voltage1")
        if voltage.isOnline():
            global volt
            volt = voltage.get_currentValue()
            #print("Volt : ",volt)
            #if btnVolt["bg"]=="white":
            #    volt == 45
        else:
            volt = 55
     
     
     
    volt = 0.0
     
     
    def b1():
        global state
        print("3")
        if state == 2:
            state = 3
        elif state == 3:
            state = 2
        print(state)
        a1()
     
    def a1():
        global state
        if state == 3:
            machine1Carte2["bg"]="red"
            if reel["bg"] == "red":
                print("allumer machine 3 REEL")
                M1C2()
            else:
                print("allumer machine 3 SIMU")
        elif state == 2:
            machine1Carte2["bg"]="white"
            if reel["bg"] == "red":
                print("eteindre machine 3 REEL")
                M1C2()
            else:
                print("eteindre machine 3 SIMU")
     
        return "machine 3"
     
    def b2():
        global state
        print("6")
        if state == 5:
            state = 6
        elif state == 6:
            state = 5
        print(state)
        a2()
     
    def a2():
        global state
        if state == 6:
            machine1Carte3["bg"]="red"
            if reel["bg"] == "red":
                print("allumer machine 6 REEL")
                M1C3()
            else:
                print("allumer machine 6 SIMU")
        elif state == 5:
            machine1Carte3["bg"]="white"
            if reel["bg"] == "red":
                print("eteindre machine 6 REEL")
                M1C3()
            else:
                print("eteindre machine 6 SIMU")
        return "machine6"
     
    def b3():
        global state
        print("1")
        if state == 0:
            state = 1
        elif state == 1:
            state = 0
        print(state)
        a3()
     
    def a3():
        global state
        if state == 1:
            machine2Carte1["bg"]="red"
            if reel["bg"] == "red":
                print("allumer machine 1 REEL")
                M2C1()
            else:
                print("allumer machine 1 SIMU")
        elif state == 0:
            machine2Carte1["bg"]="white"
            if reel["bg"] == "red":
                print("eteindre machine 1 REEL")
                M2C1()
            else:
                print("eteindre machine 1 SIMU")
        return "machine1"
     
    def b4():
        global state
        print("4")
        if state == 3:
            state = 4
        elif state == 4:
            state = 3
        print(state)
        a4()
     
    def a4():
        global state
        if state == 4:
            machine2Carte2["bg"]="red"
            if reel["bg"] == "red":
                print("allumer machine 4 REEL")
                M2C2()
            else:
                print("allumer machine 4 SIMU")
        elif state == 3:
            machine2Carte2["bg"]="white"
            if reel["bg"] == "red":
                print("eteindre machine 4 REEL")
                M2C2()
            else:
                print("eteindre machine 4 SIMU")
        return "machine4"
    def b5():
        global state
        print("7")
        if state == 7:
            state = 6
        elif state == 6:
            state = 7
        print(state)
        a5()
     
    def a5():
        global state
        if state == 7:
            machine2Carte3["bg"]="red"
            if reel["bg"] == "red":
                print("allumer machine 7 REEL")
                M2C3()
            else:
                print("allumer machine 7 SIMU")
        elif state == 6:
            machine2Carte3["bg"]="white"
            if reel["bg"] == "red":
                print("eteindre machine 7 REEL")
                M2C3()
            else:
                print("eteindre machine 7 SIMU")
        return "machine7"
     
    def b6():
        global state
        print("2")
        if state == 2:
            state = 1
        elif state == 1:
            state = 2
        print(state)
        a6()
     
    def a6():
        global state
        if state == 2:
            machine3Carte1["bg"]="red"
            if reel["bg"] == "red":
                print("allumer machine 2 REEL")
                M3C1()
            else:
                print("allumer machine 2 SIMU")
        elif state == 1:
            machine3Carte1["bg"]="white"
            if reel["bg"] == "red":
                print("eteindre machine 2 REEL")
                M3C1()
            else:
                print("eteindre machine 2 SIMU")
        return "machine2"
     
    def b7():
        global state
        print("5")
        if state == 4:
            state = 5
        elif state == 5:
            state = 4
        a7()
     
    def a7():
        global state
        if state == 5:
            machine3Carte2["bg"]="red"
            if reel["bg"] == "red":
                print("allumer machine 5 REEL")
                M3C2()
            else:
                print("allumer machine 5 SIMU")
        elif state == 4:
            machine3Carte2["bg"]="white"
            if reel["bg"] == "red":
                print("eteindre machine 5 REEL")
                M3C2()
            else:
                print("eteindre machine 5 SIMU")
        return "machine5"
     
    def b8():
        global state
        print("8")
        if state == 7:
            state = 8
        elif state == 8:
            state = 7
        print(state)
        a8()
     
    def a8():
        global state
        if state == 8:
            machine3Carte3["bg"]="red"
            if reel["bg"] == "red":
                print("allumer machine 8 REEL")
                M3C3()
            else:
                print("allumer machine 8 SIMU")
        elif state == 7:
            machine3Carte3["bg"]="white"
            if reel["bg"] == "red":
                print("eteindre machine 8 REEL")
                M3C3()
            else:
                print("eteindre machine 8 SIMU")
        return "machine8"
     
    #pool=(a1, a2, a3, a4, a5, a6, a7, a8)
    pool=(a3, a6, a1, a4, a7, a2, a5, a8)
     
    state=0
    etap = 0
     
    def do():
        if auto["bg"] == "white":
            auto["bg"] = "red"
        root.bouton_flag = True if root.bouton_flag == False else False
        def callback():
            currentTimeDate = datetime.datetime.now()
            currentTime = currentTimeDate.strftime('%H:%M:%S')
            global state
            global pool
            global etap
            voltage()
            global volt
            #volt = 55
            if volt > 53.5 and volt <= 55 and root.bouton_flag:
                voltage()
                if reel["bg"] == "red":
                    print("1ER check attendre 5 seconde")
                    print(volt," V")
                if volt > 53.5 and volt <= 55 and root.bouton_flag:
                    if reel["bg"] == "red":
                        print("2eme check attendre 5 seconde")
                        voltage()
                        print(volt," V")
                    if volt > 53.5 and volt <= 55 and root.bouton_flag:
                        if reel["bg"] == "red":
                            print("3eme check attendre 5 seconde")
                            voltage()
                            print(volt," V") 
                        if volt > 53.5 and volt <= 55 and root.bouton_flag:
                            print("3eme check GO")
                            if state >= len(pool):
                                print("(%d) - Impossible, plus de machine à allumer" % state)
                                #print("State = ", state)
                                etap = 1
                            else:
                                state+=1
                                print("(%d) - Allumage %s" % (state, pool[state-1]()))
                                #(state, pool[state-1]())
                                #print("State = ", state)
                                etap = 2
     
     
     
     
            elif volt < 49:
                if state <= 0:
                    print("(%d) - Impossible, plus de machine à éteindre" % state)
                    print("State = ", state)
                    etap = 3
                else:
                    state-=1
                    #print("(%d) - Extinction %s" % (state, pool[state-1]()))
                    print("(%d) - Extinction %s" % (state, pool[state]()))
                    #(state, pool[state-1]())
                    etap = 4
                    #print("State = ", state)
     
     
            else:
                print("(%d) - Rien à faire..." % state) 
                #print("State = ", state)
     
            if etap == 0:
                print("Entre 49 et 55 Attendre 10 seconde")
                print(currentTime)
                root.after(10000, callback)
            if etap == 1:
                print("attendre 2 minutes")
                print(currentTime)
                root.after(AttentePlus6, callback)
            if etap == 2:  
                print("attendre 15 minutes")
                print(currentTime)
                root.after(AttenteAllume, callback)  
     
            if etap == 3:
                print("attendre 2 minutes")
                print(currentTime)
                root.after(AttenteMoins1, callback)
            if etap == 4:
                print("attendre 10 minutes")
                print(currentTime)
                root.after(AttenteEtein, callback)
        callback()
     
    def Reel():
        if reel["bg"] == "white":
            reel["bg"] = "red"
            print("Passer en mode REEL")
        else :
            reel["bg"] = "white"
            print("Passer en mode SIMU")
     
    def clock():
        hour = time.strftime("%H")
        minute = time.strftime("%M")
        seconde = time.strftime("%S")
     
        my_label.config(text=hour + ":" + minute + ":" + seconde)
        my_label.after(1000, clock)
     
    my_label = Label(root, text="", font=("Helvetica", 48), fg="green", bg="black")
    my_label.place(relx=0.5, rely=0.1, anchor=CENTER)
     
    clock()
     
    voltage()
     
     
    def afficherVolt():
        voltage()
        global couleur
        global etap
        if volt < 49:
            couleur = "red"
            if etap == 2:
                test()
                etap = 0
        elif volt > 54:
            couleur = "orange"
        elif volt > 49 and volt< 54:
            couleur = "green"
        else:
            couleur = "orange"
        voltok.config(text=volt, fg=couleur)
        root.after(1000, afficherVolt)
     
    def prece():
        global state
        if volt<49:
            if state <= 0:
                print("(%d) - Impossible, plus de machine à éteindre" % state)
            else:
                state-=1
                print("(%d) - Extinction %s" % (state, pool[state]()))
                (state, pool[state-1]())
                root.after(100000, root)
     
    def test():
        global state
        if volt<49 and etap == 2:
            print("OOOOOOOOOOOOOOOOOOOOOOOOOOO")
            prece()
     
     
     
    def update():
     
        voltok.config(text="new text")
        my_label.config(text="new text")
     
     
     
    voltok = Label(root, text="", font=("Helvetica", 35), fg="orange", bg="black")
    voltok.place(relx=0.5, rely=0.8, anchor=CENTER)
     
    afficherVolt()
     
     
    timer = Label(root, fg='orange')
    timer.place(relx=0.7, rely=0.8, anchor=CENTER)
     
     
     
     
     
     
    reel = Button(root, text = 'REEL', command=Reel, bg="white")
    reel.place(relx=0.1, rely=0.1, anchor=CENTER)
     
    machine1Carte2 = Button(root, text = 'Machine 1 Carte 2', command = b1, bg="white")
    machine1Carte2.place(relx=0.2, rely=0.4, anchor=CENTER)
     
    machine1Carte3 = Button(root, text = 'Machine 1 Carte 3', command = b2, bg="white")
    machine1Carte3.place(relx=0.2, rely=0.5, anchor=CENTER)
     
    machine2Carte1 = Button(root, text = 'Machine 2 Carte 1', command = b3, bg="white")
    machine2Carte1.place(relx=0.5, rely=0.3, anchor=CENTER)
     
    machine2Carte2 = Button(root, text = 'Machine 2 Carte 2', command = b4, bg="white")
    machine2Carte2.place(relx=0.5, rely=0.4, anchor=CENTER)
     
    machine2Carte3 = Button(root, text = 'Machine 2 Carte 3', command = b5, bg="white")
    machine2Carte3.place(relx=0.5, rely=0.5, anchor=CENTER)
     
    machine3Carte1 = Button(root, text = 'Machine 3 Carte 1', command = b6, bg="white")
    machine3Carte1.place(relx=0.8, rely=0.3, anchor=CENTER)
     
    machine3Carte2 = Button(root, text = 'Machine 3 Carte 2', command = b7, bg="white")
    machine3Carte2.place(relx=0.8, rely=0.4, anchor=CENTER)
     
    machine3Carte3 = Button(root, text = 'Machine 3 Carte 3', command = b8, bg="white")
    machine3Carte3.place(relx=0.8, rely=0.5, anchor=CENTER)
     
    auto = Button(root, text="Automatique", bg="white", command=do)
    auto.place(relx=0.5, rely=0.6, anchor=CENTER)
     
    root.mainloop()

  3. #3
    Membre Expert
    Avatar de MPython Alaplancha
    Homme Profil pro
    Paysan à 3 francs six sous
    Inscrit en
    Juin 2018
    Messages
    923
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Pyrénées Orientales (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Paysan à 3 francs six sous
    Secteur : Agroalimentaire - Agriculture

    Informations forums :
    Inscription : Juin 2018
    Messages : 923
    Billets dans le blog
    8
    Par défaut
    Bonjour,
    je sais qu'il existe .after_cancel mais je n'arrive pas à le faire fonctionner
    Il te faut référencer after():
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    machineTruc = after(10, my_func)
    ...
    after_cancel(machineTruc)

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Petit problème avec mon code sur Unity3d
    Par OmegaNeos117 dans le forum C#
    Réponses: 0
    Dernier message: 10/01/2020, 21h55
  2. Petite interrogation sur mon code.
    Par morion dans le forum AJAX
    Réponses: 2
    Dernier message: 14/11/2016, 09h21
  3. Gros problème sur mon pc
    Par cat2275 dans le forum Sécurité
    Réponses: 9
    Dernier message: 11/12/2009, 09h38
  4. [débutant] Un petit problème avec mon code
    Par Muesko dans le forum Débuter
    Réponses: 3
    Dernier message: 28/08/2008, 17h12
  5. petit probleme sur mon code
    Par MORPHEUS50 dans le forum Balisage (X)HTML et validation W3C
    Réponses: 2
    Dernier message: 13/05/2007, 18h16

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