Bonjour, je me heurte à une problème lors de la programmation d'un programme de cryptographie.

je n'arrive pas à récupérer les variables qui sont dans une fonction.

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
from tkinter import *
 
#-------------------------On définis les fonctions--------------------------
 
def fn1() :
    def valider() :
 
        a = s.get()
        b = sp1.get()
        c = sp2.get()
        return[a, b, c]
 
        fn.destroy
 
    fn = Toplevel()
    fn.geometry("300x200")
 
    messagenoncodé = Label(fn, text = "Votre message doit être en majuscules uniquement!").pack()
 
    entryVar = StringVar()
    s = Entry( fn, textvariable = StringVar() )
    s.pack( side=TOP )
 
    cond1 = Label(fn, text="Le premier coéfficient doit être impair !").pack()
 
    spinVar1 = IntVar()
    sp1 = Spinbox( fn, from_=0, to=26, textvariable = IntVar() )
    sp1.pack()
 
    spinVar2 = IntVar()
    sp2 = Spinbox( fn, from_=0, to=999, textvariable = IntVar() )
    sp2.pack()
 
    Canvas(fn, width = 50, height = 10).pack()
 
    but1 = Button(fn, text ='Valider', command = valider).pack(side = LEFT, padx = 3, pady = 3)
    but4 = Button(fn, text= 'Chiffrer', command = codage).pack(side = TOP, padx = 3, pady = 3)
    but2 = Button(fn, text ='Dechiffrer').pack(side = RIGHT, padx = 3, pady = 3)
    but3 = Button(fn, text = 'Quitter', command = fn.destroy).pack(side = BOTTOM, padx = 3, pady = 3)
 
    lab = Label(fn).pack
 
 
 
 
 
def codage() :
    x = valider[a]
    for C in x:
        y=(num(C)*(valider[b])+(valider[c]))%26
        print(lettre(y), end="")

Comment faire pour récupérer les valeurs de a, b et c pour pouvoir les utiliser dans la fonction codage?


Merci de votre attention