Bonjour, je suis débutant et je n'arrive pas à récupérer la valeur dans entry de ce programme python

le programme ouvre une interface, on peut insérer du texte dans un entry ( GLineEdit_255) mais je n'arrive pas a récupérer la valeur

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
import tkinter as tk
import tkinter.font as tkFont
from tkinter import *
class App:
    def __init__(self, root):
        # setting title
        root.title("Dice Game")
        # setting window size
        width = 487
        height = 339
        screenwidth = root.winfo_screenwidth()
        screenheight = root.winfo_screenheight()
        alignstr = '%dx%d+%d+%d' % (width, height, (screenwidth - width) / 2, (screenheight - height) / 2)
        root.geometry(alignstr)
        root.resizable(width=False, height=False)
 
        self.entry_value = tk.StringVar()  # Variable to store the value of the entry
 
        GLineEdit_255 = tk.Entry(root, textvariable=self.entry_value)  # Attach the variable to the Entry widget
        GLineEdit_255["bg"] = "#e7e7e7"
        GLineEdit_255["borderwidth"] = "3px"
        ft = tkFont.Font(family='Times', size=18)
        GLineEdit_255["font"] = ft
        GLineEdit_255["fg"] = "#333333"
        GLineEdit_255["justify"] = "center"
        GLineEdit_255["text"] = "Insert number"
        GLineEdit_255["relief"] = "sunken"
        GLineEdit_255.place(x=160, y=180, width=157, height=59)
 
        GLabel_968 = tk.Label(root)
        ft = tkFont.Font(family='Times', size=28)
        GLabel_968["font"] = ft
        GLabel_968["fg"] = "#333333"
        GLabel_968["justify"] = "center"
        GLabel_968["text"] = "Choose a random number"
        GLabel_968.place(x=0, y=110, width=485, height=75)
 
        GLabel_184 = tk.Label(root)
        GLabel_184["activebackground"] = "#dedede"
        GLabel_184["cursor"] = "arrow"
        ft = tkFont.Font(family='Times', size=48)
        GLabel_184["font"] = ft
        GLabel_184["fg"] = "#333333"
        GLabel_184["justify"] = "center"
        GLabel_184["text"] = "Dice Game"
        GLabel_184.place(x=50, y=20, width=379, height=61)
 
        GButton_772 = tk.Button(root, command=self.on_done_button_click)  # Assign a function to the button click event
        GButton_772["bg"] = "#f0f0f0"
        ft = tkFont.Font(family='Times', size=38)
        GButton_772["font"] = ft
        GButton_772["fg"] = "#000000"
        GButton_772["justify"] = "center"
        GButton_772["text"] = "Done"
        GButton_772["relief"] = "raised"
        GButton_772.place(x=140, y=260, width=199, height=60)
 
    def on_done_button_click(self):
        # This method will be called when the "Done" button is clicked
        entry_text = self.entry_value.get() # Get the value from the Entry widget
        print("Value entered:"+entry_text)   # Do whatever you want with the value
 
if __name__ == "__main__":
 root = tk.Tk()
 app = App(root)
 root.mainloop()