Label qui ne s'affiche pas.

Résolu

Bonjour,

J'ai le code suivant:

label = Label(fenetre, anchor=NW, bg="Black", texte="1", fg="White")
label.pack()
petit_font = "-size 5"
label.configure(font = petit_font)

Quand je l'exécute avec IDLE le label s'affiche, mais quand je double clique sur le fichier .py la fenêtre s'ouvre sans le label. Comment puis-je faire pour l'afficher?

Merci

3 réponses

  • Votes
  • Date
  • Date décroissante
  1. Bonjour,

    Ce n'est pas texte = "1" mais text = "1"

    (c'est de l'anglais)

    1. Oui oui faute de frappe.

      Mais ça ne marche toujours pas

  2. ah ?

    chez moi, ca marche

    # -*- coding:Utf-8 -*-
    
    from tkinter import *
    
    WIDTH, HEIGHT = 600, 400
    
    main_win = Tk()
    main_win.configure(background = 'grey')
    main_win.title('Test GUI')
    main_win.geometry(str(WIDTH)+'x'+str(HEIGHT)+'+300+100')
    
    label = Label(main_win, anchor=NW, bg="Black", text="1", fg="White")
    label.pack()
    petit_font = "-size 5"
    label.configure(font = petit_font)
    
    main_win.mainloop()
    1. C'est bon j'ai trouvé.

      Merci quand même.