Bonsoir je débute en langage python et j'ai une question à vous posez , est-il possible d'appeler une fonction qui est dans une autre fonction ? je m'explique voici mon code :

le problème de mon code c'est la commande=applyToLabel appelle comme son nom l'indique la fonction appluToLabel mon qui elle se trouve dans une fonction.... Si qlq peut m'aider je suis preneur....
Merci
cdt


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
 
import tkinter as tk
 
root=tk.Tk()
root.title("test")
root.geometry("1200x600")
 
 
 
box_list_2 = []
def func_1():
    def applyToLabel():
        xx=size.get()
        for i in range(xx):
            element = box_list[i].get()
            box_list_2.append(element)
    print(box_list_2)
 
 
 
 
 
box_list = []
 
def boxes():
    xx=size.get()
    for i in range(xx):
        box=tk.Entry(root)
        box.pack()
        box_list.append(box)
    ApplytoLabel1=tk.Button(root,text="Submit To Array",command=applyToLabel)
    ApplytoLabel1.pack()
 
 
 
 
Array = tk.Frame(root)
Array.pack()
 
text1=tk.Label(Array,text="Enter number of values :",
               font="Arial 10 bold")
text1.grid(row=0,column=0,sticky="w")
 
size=tk.IntVar()
 
ArraySize=tk.Entry(Array,textvariable=size)
ArraySize.grid(row=0,column=1,sticky="w")
 
SizeofArray=tk.Button(Array,text="Ok",command=boxes)
SizeofArray.grid(row=0,column=2,sticky="w")
 
 
 
 
 
root.mainloop()