Reputation: 13
I'm making a program that display the location of a vehicule on a map, I use "tkintermapview" to display a map, and tkinter to display stuff on it (road it's suppose to be on, icone to show where it is and a trail to show where it went). I want to show the historic of where it went during the last X seconds/minuts, in order to do that I ask via a spinbox a value of X seconds.
My problem is that I can't get the value in a variable ( new variable) outside of the fonction
I tried a lot of stuff, mostly declaring the variable in different ways. It was suggested to me to use threading but idk how to use it so I'm looking for another option. Not the actual whole code just something to show where i'm strugling
import tkinter as tk
from tkinter import simpledialog
# Créer une fenêtre principale
root = tk.Tk()
root.title("TinkerMapView avec Entrée Numérique")
# Fonction pour récupérer la valeur entrée
def get_user_input():
user_input = simpledialog.askfloat("Input", "Entrez une valeur numérique:")
if user_input is not None:
print(f"Valeur entrée: {user_input}")#the goal of this print is to see if the value is correct (i dont want to print anything otherwise)
# Ajouter un bouton pour obtenir l'entrée de l'utilisateur
get_input_button = tk.Button(root, text="Entrer une valeur numérique", command=get_user_input)
get_input_button.pack(pady=20)
#//////////////////////////////
#I want to use the variable here
#//////////////////////////////
# Lancer la boucle principale de Tkinter
root.mainloop()
Upvotes: 0
Views: 29