IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Tkinter Python Discussion :

methode pack bug :(


Sujet :

Tkinter Python

  1. #1
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Septembre 2008
    Messages
    52
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Septembre 2008
    Messages : 52
    Points : 29
    Points
    29
    Par défaut methode pack bug :(
    je cherche a afficher ,après avoir appuyer sure entrée la même chose sure un autre label (text?)
    le code:
    print entree.get()
    devrai permettre d'obtenir le résulta dans la console, mai je ne c 'es pas comment l'affecter a un label ? #retun ?

    Bug: la méthode:
    pack()
    empêche la fenêtre de s'afficher ??

    Note si vou voulez tester le code pensez a mettre le chemin du fichier pour l'image a la variable: my_file


    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
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
     
    #!/usr/bin/env python
    # -*- coding:Utf-8 -*-
     
    from Tkinter import *
    #paquet python-pil
    from PIL import Image,ImageTk
    class Application:
        def __init__(self):
     
     
            #self.root = Tk()
            self.root =Tk()
            L=300
            H=225
            H_image=L/2
            L_image=H/2
     
            my_file = "/home/taz/Desktop/python/3.jpg"
            can = Canvas(self.root, width =L, height =H, bg ='white')
            mon_image=ImageTk.PhotoImage(file=my_file)
            can.create_image(H_image,L_image,image=mon_image)
            can.pack()
     
     
            # création de widgets 'Label' et 'Entry' :
            txt1 = Label(self.root, text ='Versions')
            txt2 = Label(self.root, text ='Nice')
            txt3 = Label(self.root, text ='Ram')
            txt4 = Label(self.root, text ='Source')
            txt5 = Label(self.root, text ='Répertoire tar')
            txt6 = Label(self.root, text ='Static')
            txt7 = Label(self.root, text ='Point de montage en ram')
            txt8 = Label(self.root, text ='TempMove')
            txt9 = Label(self.root, text ='Module')
     
            entr1 = Entry(self.root)
            entr2 = Entry(self.root)
            entr3 = Entry(self.root)
            entr4 = Entry(self.root)
            entr5 = Entry(self.root)
            entr6 = Entry(self.root)
            entr7 = Entry(self.root)
            entr8 = Entry(self.root)
            entr9 = Entry(self.root)
     
            txt1.grid(row =1, sticky =E)
            txt2.grid(row =2, sticky =E)
            txt3.grid(row =3, sticky =E)
            txt4.grid(row =4, sticky =E)
            txt5.grid(row =5, sticky =E)
            txt6.grid(row =6, sticky =E)
            txt7.grid(row =7, sticky =E)
            txt8.grid(row =8, sticky =E)
            txt9.grid(row =9, sticky =E)
     
     
     
            entr1.grid(row =1, column =2)
            entr2.grid(row =2, column =2)
            entr3.grid(row =3, column =2)
            entr4.grid(row =4, column =2)
            entr5.grid(row =5, column =2)
            entr6.grid(row =6, column =2)
            entr7.grid(row =7, column =2)
            entr8.grid(row =8, column =2)
            entr9.grid(row =9, column =2)
     
            def evaluer(event):
                print entree.get()
            entree = Entry(self.root)
            entree.bind("<Return>", evaluer)
            chaine = Label(txt9)
            bou1 = Button(self.root, text='Quitter', command = self.root.destroy)
            #bou1.pack()
            #entree.pack()
            #chaine.pack()
            can.grid(row =2, column =4, rowspan =13, padx =0, pady =0)
     
            self.root.mainloop()
    f = Application()
    Merci d'avance

  2. #2
    Membre expérimenté Avatar de pacificator
    Profil pro
    Inscrit en
    Août 2006
    Messages
    1 074
    Détails du profil
    Informations personnelles :
    Âge : 45
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 1 074
    Points : 1 728
    Points
    1 728
    Par défaut
    extrait de la faq:
    Il est fortement conseillé d'utiliser le même gestionnaire de mise en place dans un même conteneur.
    .
    Je ne suis pas utilisateur de Tkinter mais je crois que ton problème est là (mélange de pack et grid).

    Si un aficionados de Tkinter pouvait confirmer

  3. #3
    Membre averti
    Homme Profil pro
    Responsable du parc et des réseaux de télécommunication
    Inscrit en
    Mai 2003
    Messages
    290
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Responsable du parc et des réseaux de télécommunication
    Secteur : Industrie

    Informations forums :
    Inscription : Mai 2003
    Messages : 290
    Points : 388
    Points
    388
    Par défaut
    En effet, ne jamais mélanger pack() et grid().
    Tu peux d'ailleurs supprimer Pour ta question :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
        def evaluer(event):
            txt= entree.get()
            MonLabel.config(text=txt)

  4. #4
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Septembre 2008
    Messages
    52
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Septembre 2008
    Messages : 52
    Points : 29
    Points
    29
    Par défaut
    Merci en utilisan grid sa mar impec

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [Objective-C] bug avec class NSDictionnary, methode bug
    Par manonthemoon dans le forum Objective-C
    Réponses: 1
    Dernier message: 21/09/2012, 10h53
  2. Réponses: 6
    Dernier message: 13/06/2011, 12h08
  3. Gros bug à l'installation du service pack 2
    Par habasque dans le forum Windows XP
    Réponses: 3
    Dernier message: 23/02/2009, 22h41
  4. [BUG] Zend_Db_Select query method
    Par sekaijin dans le forum Zend_Db
    Réponses: 2
    Dernier message: 13/10/2007, 17h19

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo