Aide pour affichage texte sur tkinter

a marqué ce sujet comme résolu.

Bonjour à tous, Je vous sollicite car j’aimerais afficher un texte dans une fenêtre tkinter. Le seul problème est que ce texte change car il provient d’une fonction que j’ai défini mais je ne veux pas que le résultat s’imprime dans ma console. Je vous mets la partie du code susceptible de vous être utile pour répondre à mon problème. Merci d’avance.

def plus_court_chemin():

    # récupération du code puis du numéro de la station de départ
    station_depart_name = liste_stations_depart.get()
    station_depart_code = stationCodes.get(station_depart_name)
    NumVilleDepart = stations.get(station_depart_code)

    # récupération du code puis du numéro de la station d'arrivée
    station_dest_name = liste_stations_arrivee.get()
    station_dest_code = stationCodes.get(station_dest_name)
    NumVilleDest = stations.get(station_dest_code)

    print("Calcul du plus court chemin entre", station_depart_name, "et", station_dest_name)

    DIJ = list()  # la liste DIJ mémorise les données du tableau (cf. étape 1)
    for i in range(nombreStations):
        DIJ.append([float("inf"), "X", "N"])  

    ville_select = NumVilleDepart  # numéro de la ville sélectionnée; 0 = ville de départ
    pville_select = 0 # on initialise la variable 
    dist_interm = 0  # distance pour arriver à la ville sélectionnée; 0 au départ

    while ville_select != NumVilleDest:
        DIJ[ville_select][0] = dist_interm
        DIJ[ville_select][2] = "O"
        minimum = float("inf")

        for n in range(0, nombreStations):
            if DIJ[n][2] == "N":
                dist = matrice[ville_select][n]
                dist_totale = dist_interm + dist

                if dist != 0 and dist_totale < DIJ[n][0]:
                    DIJ[n][0] = dist_totale
                    DIJ[n][1] = ville_select

                if DIJ[n][0] < minimum:
                    minimum = DIJ[n][0]
                    pville_select = n

        ville_select = pville_select  # pville_select = numéro de la prochaine ville sélectionnée
        dist_interm = minimum

    ville = NumVilleDest
    chemin = [NumVilleDest]
    
    while ville != NumVilleDepart:
        ville = DIJ[ville][1]
        chemin.append(ville)

    chemin.reverse()  
    
    print("Le plus court chemin passe par les stations :", chemin)
    print("La distance totale de votre trajet est :", DIJ[pville_select][0], "km")
    print("Le temps de votre trajet est environ :", (round((DIJ[pville_select][0]/13)*60)), "min")

Je cherche à afficher les 3 dernières lignes dans mon interface graphique… J’ai essayé avec la méthode labelou l’afficher dans un canvassans résultat. J’ai essayé ça:

affichage = tk.Label(fenetre, text= "Le plus court chemin passe par les stations :", chemin,"La distance totale de votre trajet est :", DIJ[pville_select][0], "km", "Le temps de votre trajet est environ :", (round((DIJ[pville_select][0]/13)*60)), "min")
affichage.pack()

On me retourne :

positonal argument follows keyword argument
+0 -0

Bonsoir Théo ISN 001, tu peux procéder comme ceci:

# Création de notre fenetre
fen = Tk()
fen.title("Court Chemin")
fen.geometry("750x470")
fen.resizable(width=NO, height=NO)
fen.config(bg='#6b6bb6')


# Ajout du label dans notre fenetre et ajout de notre phrase

Label(fen, text="Le plus court chemin passe par les stations :"+chemin, font=("Times new roman", 16, "bold\
"), fg="white", bg='#6b6bb6').place(x=140, y=15)

Tu vais de la même chose pour les autres.

J’espère que ça va t’aider.

+0 -0

Je te le mets en dessous: Tu ne pourras pas avoir l’image du plan mais elle ne te sera pas utile de toute façon.

import tkinter as tk
from tkinter import *
from tkinter import ttk

fenetre = tk.Tk()
fenetre.title('RATPlan')

nombreStations = 57

S1811 = [0, 0.62, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]  # Argentine
S1812 = [0.62, 0, 0.43, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]  # Charles de Gaulle - Étoile
S1808 = [0, 0.43, 0, 0.72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0]  # Saint-François-Xavier
S2103 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] #Cadet

matrice = [S1811, S1812, S1808, S1807, S1001, S1002, S1101, S1102, S0112, S0115, S1113, S1104, S0604, S0605, S0607, S1114, S1115, S0109, S0108, S0114, S0101, S0104, S0215, S1708, S1004, S1715, S1714, S1809, S1801, S1803, S1805, S0610,
           S1107, S1106, S3109, S2102, S2101, S1103, S0113, S1007, S1008, S1003, S1012, S1009, S1804, S0609, S0209, S0210, S1014, S1013, S3108, S1108, S0212, S1707, S0105, S0206, S2103]

stationCoords = {
     "S1811": [1, 1],
     # TODO etc
}

stationCodes = {
    "Alma Marceau": "S1803",
   "Argentine": "S1811",
   "Assemblée Nationale": "S1013",
   "Bir-Hakeim": "S1004",
   "Boissière": "S1714",
   "Bonne Nouvelle": "S1108",
   "Bourse": "S1104",
   "Cadet": "S2103",
   "Champs Élysée Clémenceau": "S1001",
   "Charles De Gaulle Etoile": "S1812",
   "Chatelêt": "S0108",
   "Chaussée D’Antin La Fayette": "S2101",
   "Cité": "S0114",
   "Cluny la Sorbonne": "S0105",
   "Concorde": "S1002",
   "Dupleix ": "S1707",
   "École Militaire": "S1007",
   "Étienne Marcel": "S1115",
   "Franklin D. Roosevelt": "S1807",
   "George V": "S1808",
   "Grands Boulevards": "S1106",
   "Havre Caumartin": "S0607",
   "Hôtel de Ville": "S0115",
   "Iéna": "S1801",
   "Invalides": "S1009",
   "Kléber": "S1809",
   "La Tour-Maubourg": "S1008",
   "Le Peletier": "S2102",
   "Les Halles": "S0109",
   "Louvre-Rivoli": "S0112",
   "Madeleine": "S1003",
   "Miromesnil": "S1804",
   "Notre Dame de Lorette": "S3109",
   "Odéon": "S0104",
   "Opéra": "S0605",
   "Palais Royal Musée du Louvre": "S1102",
   "Passy": "S1708",
   "Pont-Neuf": "S0113",
   "Pyramides": "S1103",
   "Quatre Septembre": "S0604",
   "Réaumur Sebastopol": "S1114",
   "Richelieu Drouot": "S1107",
   "Rue du Bac": "S0210",
   "Saint-Augustin": "S0610",
   "Saint-François-Xavier": "S0206",
   "Saint Germain des prés": "S0215",
   "Saint Lazare": "S0609",
   "Saint Michel": "S0101",
   "Saint Philippe du Roule": "S1805",
   "Saint Sulpice": "S0212",
   "Sentier": "S1113",
   "Sèvres-Babylone": "S0209",
   "Solférino": "S1014",
   "Trinité d’Estienne d’Orves": "S3108",
   "Trocadéro": "S1715",
   "Tuileries": "S1101",
   "Varenne": "S1012",
   
}

stations = {'S1811': 0, 'S1812': 1, 'S1808': 2, 'S1807': 3, 'S1001': 4, 'S1002': 5, 'S1101': 6, 'S1102': 7, 'S0112': 8, 'S0115': 9, 'S1113': 10, 'S1104': 11, 'S0604': 12, 'S0605': 13, 'S0607': 14, 'S1114': 15, 'S1115': 16, 'S0109': 17,
            'S0108': 18, 'S0114': 19, 'S0101': 20, 'S0104': 21, 'S0215': 22, 'S1708': 23, 'S1004': 24, 'S1715': 25, 'S1714': 26, 'S1809': 27, 'S1801': 28, 'S1803': 29, 'S1805': 30, 'S0610': 31, 'S1107': 32, 'S1106': 33, 'S3109': 34,
            'S2102': 35, 'S2101': 36, 'S1103': 37, 'S0113': 38, 'S1007': 39, 'S1008': 40, 'S1003': 41, 'S1012': 42, 'S1009': 43, 'S1804': 44, 'S0609': 45, 'S0209': 46, 'S0210': 47, 'S1014': 48, 'S1013': 49, 'S3108': 50, 'S1108': 51,
            'S0212': 52, 'S1707': 53, 'S0105': 54, 'S0206': 55, 'S2103': 56}

def plus_court_chemin():

    # récupération du code puis du numéro de la station de départ
    station_depart_name = liste_stations_depart.get()
    station_depart_code = stationCodes.get(station_depart_name)
    NumVilleDepart = stations.get(station_depart_code)

    # récupération du code puis du numéro de la station d'arrivée
    station_dest_name = liste_stations_arrivee.get()
    station_dest_code = stationCodes.get(station_dest_name)
    NumVilleDest = stations.get(station_dest_code)

    print("Calcul du plus court chemin entre", station_depart_name, "et", station_dest_name)

    DIJ = list()  # la liste DIJ mémorise les données du tableau (cf. étape 1)
    for i in range(nombreStations):
        DIJ.append([float("inf"), "X", "N"])  

    ville_select = NumVilleDepart  # numéro de la ville sélectionnée; 0 = ville de départ
    pville_select = 0 # on initialise la variable 
    dist_interm = 0  # distance pour arriver à la ville sélectionnée; 0 au départ

    while ville_select != NumVilleDest:
        DIJ[ville_select][0] = dist_interm
        DIJ[ville_select][2] = "O"
        minimum = float("inf")

        for n in range(0, nombreStations):
            if DIJ[n][2] == "N":
                dist = matrice[ville_select][n]
                dist_totale = dist_interm + dist

                if dist != 0 and dist_totale < DIJ[n][0]:
                    DIJ[n][0] = dist_totale
                    DIJ[n][1] = ville_select

                if DIJ[n][0] < minimum:
                    minimum = DIJ[n][0]
                    pville_select = n

        ville_select = pville_select  # pville_select = numéro de la prochaine ville sélectionnée
        dist_interm = minimum

    ville = NumVilleDest
    chemin = [NumVilleDest]
    
    while ville != NumVilleDepart:
        ville = DIJ[ville][1]
        chemin.append(ville)

    chemin.reverse()  
    
    print("Le plus court chemin passe par les stations :", chemin)
    print("La distance totale de votre trajet est :", DIJ[pville_select][0], "km")
    print("Le temps de votre trajet est environ :", (round((DIJ[pville_select][0]/13)*60)), "min")


texte = tk.Label(fenetre, text='Itinéraire RATP')
texte['fg'] = 'turquoise'  # Création du texte "Itinéraire RATP" de couleur turquoise
texte.pack()

plan = PhotoImage(file='plan.gif')
label = Label(image=plan)
label.pack(side=TOP, padx=5, pady=5)

liste_stations_depart = ttk.Combobox(fenetre, values=list(stationCodes.keys()))

liste_stations_depart.current(0)
liste_stations_depart.pack(side=LEFT)

liste_stations_arrivee = ttk.Combobox(fenetre, values=list(stationCodes.keys()))
liste_stations_arrivee.current(0)
liste_stations_arrivee.pack(side=LEFT)

fermer = Button(fenetre, text="fin de mon trajet", command=fenetre.destroy, relief=RAISED)
fermer.pack(side=BOTTOM)

programm_launcher = Button(fenetre, text="calculer mon itinéraire", command=plus_court_chemin, relief=RAISED)
programm_launcher.pack(side=RIGHT)


fenetre.mainloop()
+0 -0

Salut !

Cela vient du fait que ta variable chemin est de type list, or dans ton Label tu essayes de le concaténer avec une str.

Tu peux par exemple utiliser la méthode join pour obtenir une string à partir d’une liste de char (ou de string) comme ceci:

>>> chemin_list = ["a", "b", "cd", "e"]
>>> chemin_str = ''.join(chemin_list)
>>> print(chemin_str)
abcde
>>> print(type(chemin_str))
<class 'str'>
>>> 

Lorsque tu n’es pas sûr du type d’une de tes variables, tu peux toujours utiliser print(type(variable)) pour confirmer.

Salut,

Je vois que personne n’a expliqué l’erreur dans ton premier message, je me permets de le faire parce que c’est important. Les problèmes que tu as dans ce sujet étaient tous résolubles en lisant le message d’erreur, il est important que tu apprennes à les déchiffrer pour gagner en indépendance.

positonal argument follows keyword argument

Quand on appelle une fonction en Python, il y a deux façon de lui passer ses arguments : dans l’ordre dans lequel la fonction les attends (f(1, 2, 3), le positional argument du message d’erreur), ou bien en lui passant les noms des arguments aussi f(a=1, b=2, c=3) (le keyword argument du message d’erreur). La différence étant que tu peux changer l’ordre des keywords argument sans problème f(c=3, a=1, b=2). Ce que l’erreur te dit, c’est que tu as un argument sans nom qui suit un argument avec nom, ce qui est interdit. Tu ne peux pas faire f(a=1, 2, 3) par exemple. Il est possible de faire f(1, c=3, b=2) par contre.

+1 -0
Connectez-vous pour pouvoir poster un message.
Connexion

Pas encore membre ?

Créez un compte en une minute pour profiter pleinement de toutes les fonctionnalités de Zeste de Savoir. Ici, tout est gratuit et sans publicité.
Créer un compte