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

Python Discussion :

probleme Entry get()


Sujet :

Python

  1. #1
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Mars 2019
    Messages
    22
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 25
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mars 2019
    Messages : 22
    Par défaut probleme Entry get()
    Bonjour, j'ai un problème avec Entry.get (). J'aimerais récupérer les informations du formulaire dans une liste (liste_info), merci
    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
     
    from tkinter import *
     
    # reglages
    width = 800
    height = 600
    couleur = (48, 47, 47)
    couleurmes = (113, 113, 113)
     
     
    class Appli():
        def __init__(self):
            self.fenetre = Tk()
            self.fenetre.geometry("1000x600")
            self.fenetre.title('Appli')
            self.fenetre.configure(background="#cecece")
            self.fenetre.configure(highlightbackground="#cecece")
            self.fenetre.configure(borderwidth="1")
            self.fenetre.configure(relief="sunken")
            self.fenetre.attributes('-alpha', 0.98)
            self.objet()
     
     
        liste_Info = []
     
     
        def objet(self):
     
            self.listeF = ['NOM :', 'PRENOM :', 'ADRESSE :', 'N° TELE :', 'MAIL :' ]
            self.liste_Info = []
     
     
            R_span = 2
            R_pady = 70
     
            # graphique creation
     
            for x in self.listeF:
     
                global  entree
     
                x = Label(self.fenetre, text=x, bg='#cecece', fg='black')
                x.grid(row=1, column=2, rowspan =  R_span, pady = R_pady, sticky = W)
                x = Entry(self.fenetre, bg='black', fg='white')
                x.grid(row=1, column=3, rowspan=R_span, pady=R_pady, sticky = NW)
     
                print(x)
                entree = x.get()
                R_span += 1
                R_pady +=50
     
     
            self.lab_mes = Label(self.fenetre, text='MESSAGE : ', bg='#cecece', fg='black')
            self.lab_mes.grid(row=1, column=4, padx=40, rowspan = 2, sticky = W)
     
     
            self.MES = Entry(self.fenetre, bg='black', fg='white')
            self.MES.grid(row=2, column=4, padx=40, rowspan=2, ipady = 40, sticky = W)
     
     
            self.bouton = Button(self.fenetre, text='Valider', command=self.Entree_Get())
            self.bouton.grid(row=4, column=4,padx=40,sticky = NE)
     
     
            self.canphoto = Canvas(self.fenetre, width=165, height=222, bg='dark grey')
            self.canphoto.grid(row=1, column=1, rowspan=4, padx=20, pady=70,sticky = W)
     
        def Entree_Get(self):
            self.liste_Info.append(entree)
            print(self.liste_Info)
     
     
    application = Appli()
    application.fenetre.mainloop()

  2. #2
    Expert éminent
    Homme Profil pro
    Architecte technique retraité
    Inscrit en
    Juin 2008
    Messages
    21 689
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Manche (Basse Normandie)

    Informations professionnelles :
    Activité : Architecte technique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2008
    Messages : 21 689
    Par défaut
    Salut,

    Citation Envoyé par SamyPyth Voir le message
    Bonjour, j'ai un problème avec Entry.get (). J'aimerais récupérer les informations du formulaire dans une liste (liste_info)
    Pour pouvoir faire çà, il faudrait que les Entry du formulaire soient aussi dans une liste histoire d'aller récupérer les différentes valeurs à recopier.

    - W
    Architectures post-modernes.
    Python sur DVP c'est aussi des FAQs, des cours et tutoriels

  3. #3
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Mars 2019
    Messages
    22
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 25
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mars 2019
    Messages : 22
    Par défaut
    Vous pouvez me montrer la correction sil vous plait.
    Mercii d'avance.

  4. #4
    Expert éminent
    Homme Profil pro
    Architecte technique retraité
    Inscrit en
    Juin 2008
    Messages
    21 689
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Manche (Basse Normandie)

    Informations professionnelles :
    Activité : Architecte technique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2008
    Messages : 21 689
    Par défaut
    Citation Envoyé par SamyPyth Voir le message
    Vous pouvez me montrer la correction sil vous plait
    Quelle correction?
    Créer une liste d'Entry, c'est pas si compliqué et si vous n'essayez même pas vous n'y arriverez jamais.
    note: et si vous ne savez pas par où commencer ou ce que çà veut dire, vous cherchez dans votre tuto. préféré le chapitre qui parle des listes (qui est une des structures de base du langage qu'on apprend à utiliser en même temps que les boucles).

    - W
    Architectures post-modernes.
    Python sur DVP c'est aussi des FAQs, des cours et tutoriels

  5. #5
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Mars 2019
    Messages
    22
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 25
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mars 2019
    Messages : 22
    Par défaut probleme Entry get()
    voici le code mais j'ai toujours le mème probleme

    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
    82
    83
    84
    85
    86
    87
    88
    89
    90
     
     
     
    from tkinter import *
     
    # reglages
    width = 800
    height = 600
    couleur = (48, 47, 47)
    couleurmes = (113, 113, 113)
     
     
    #creation de la class
    class Appli():
        def __init__(self):
            self.fenetre = Tk()
            self.fenetre.geometry("1000x600")
            self.fenetre.title('Appli')
            self.fenetre.configure(background="#cecece")
            self.fenetre.configure(highlightbackground="#cecece")
            self.fenetre.configure(borderwidth="1")
            self.fenetre.configure(relief="sunken")
            self.fenetre.attributes('-alpha', 0.98)
            self.objet()
     
     
     
     
        #methode pour objets
        def objet(self):
     
            self.listeF = ['NOM :', 'PRENOM :', 'ADRESSE :', 'N° TELE :', 'MAIL :' ]
     
            self.liste_Entry = []
     
            self.liste_Info = []
     
     
            R_span = 2
            R_pady = 70
     
            #creation graphique
     
            for x in self.listeF:
     
                x = Label(self.fenetre, text=x, bg='#cecece', fg='black')
                x.grid(row=1, column=2, rowspan =  R_span, pady = R_pady, sticky = W)
                x = Entry(self.fenetre, bg='black', fg='white')
     
                self.liste_Entry.append(x)
     
                x.grid(row=1, column=3, rowspan=R_span, pady=R_pady, sticky = NW)
     
                #recuperation de la list
                for l in self.liste_Entry:
                    self.rec_ent = l.get()
     
                    print(self.rec_ent)
     
                R_span += 1
                R_pady +=50
     
     
            self.lab_mes = Label(self.fenetre, text='MESSAGE : ', bg='#cecece', fg='black')
            self.lab_mes.grid(row=1, column=4, padx=40, rowspan = 2, sticky = W)
     
     
            self.MES = Entry(self.fenetre, bg='black', fg='white')
            self.MES.grid(row=2, column=4, padx=40, rowspan=2, ipady = 40, sticky = W)
     
     
            self.bouton = Button(self.fenetre, text='Valider', command=self.Entree_Get)
            self.bouton.grid(row=4, column=4,padx=40,sticky = NE)
     
     
            self.canphoto = Canvas(self.fenetre, width=165, height=222, bg='dark grey')
            self.canphoto.grid(row=1, column=1, rowspan=4, padx=20, pady=70,sticky = W)
     
     
        #methode du bouton valid
        def Entree_Get(self):
     
            self.liste_Info.append(self.rec_ent)
     
     
     
     
    #variable lié à l'application
    application = Appli()
    application.fenetre.mainloop()

  6. #6
    Expert éminent
    Homme Profil pro
    Architecte technique retraité
    Inscrit en
    Juin 2008
    Messages
    21 689
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Manche (Basse Normandie)

    Informations professionnelles :
    Activité : Architecte technique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2008
    Messages : 21 689
    Par défaut
    Citation Envoyé par SamyPyth Voir le message
    voici le code mais j'ai toujours le mème probleme
    maintenant, il faut juste réfléchir un peu: à quoi sert d'avoir un Button Valider permettant à l'utilisateur de dire "j'ai entré les infos" si vous lisez le contenu des Entry "avant" qu'il ait cliqué sur le Button?

    - W
    Architectures post-modernes.
    Python sur DVP c'est aussi des FAQs, des cours et tutoriels

  7. #7
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Mars 2019
    Messages
    22
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 25
    Localisation : France, Bas Rhin (Alsace)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mars 2019
    Messages : 22
    Par défaut
    merci, je viens de trouver l'erreur.
    voila le code qui fonctionne

    Code py : 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
    from tkinter import *
     
    # reglages
    width = 800
    height = 600
    couleur = (48, 47, 47)
    couleurmes = (113, 113, 113)
     
     
    # creation de la class
    class Appli():
        def __init__(self):
            self.fenetre = Tk()
            self.fenetre.geometry("1000x600")
            self.fenetre.title('Appli')
            self.fenetre.configure(background="#cecece")
            self.fenetre.configure(highlightbackground="#cecece")
            self.fenetre.configure(borderwidth="1")
            self.fenetre.configure(relief="sunken")
            self.fenetre.attributes('-alpha', 0.98)
            self.objet()
     
        # methode pour objets
        def objet(self):
     
            self.listeF = ['NOM :', 'PRENOM :', 'ADRESSE :', 'N° TELE :', 'MAIL :']
     
            self.liste_Entry = []
     
            self.liste_Info = []
     
            R_span = 2
            R_pady = 70
     
            # creation graphique
     
            for x in self.listeF:
     
                x = Label(self.fenetre, text=x, bg='#cecece', fg='black')
                x.grid(row=1, column=2, rowspan=R_span, pady=R_pady, sticky=W)
                x = Entry(self.fenetre, bg='black', fg='white')
     
                self.liste_Entry.append(x)
     
                x.grid(row=1, column=3, rowspan=R_span, pady=R_pady, sticky=NW)
     
                # recuperation de la list
     
     
                R_span += 1
                R_pady += 50
     
            self.lab_mes = Label(self.fenetre, text='MESSAGE : ', bg='#cecece', fg='black')
            self.lab_mes.grid(row=1, column=4, padx=40, rowspan=2, sticky=W)
     
            self.MES = Entry(self.fenetre, bg='black', fg='white')
            self.MES.grid(row=2, column=4, padx=40, rowspan=2, ipady=40, sticky=W)
     
            self.bouton = Button(self.fenetre, text='Valider', command=self.Entree_Get)
            self.bouton.grid(row=4, column=4, padx=40, sticky=NE)
     
            self.canphoto = Canvas(self.fenetre, width=165, height=222, bg='dark grey')
            self.canphoto.grid(row=1, column=1, rowspan=4, padx=20, pady=70, sticky=W)
     
        # methode du bouton valid
        def Entree_Get(self):
     
            for l in self.liste_Entry:
                self.rec_ent = l.get()
                self.liste_Info.append(self.rec_ent)
     
                print(self.rec_ent)
     
     
    # variable lié à l'application
    application = Appli()
    application.fenetre.mainloop()

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

Discussions similaires

  1. Probleme apt-get upgrade
    Par atrhacker dans le forum Debian
    Réponses: 11
    Dernier message: 01/12/2009, 18h38
  2. Probleme de GET et SESSION
    Par sebix dans le forum Langage
    Réponses: 8
    Dernier message: 04/01/2009, 15h15
  3. Probleme APT-get update avec Kubuntu
    Par rockt13 dans le forum Ubuntu
    Réponses: 6
    Dernier message: 05/11/2008, 15h13
  4. probleme apt-get upgrade avec version beta
    Par Nibeck dans le forum Bubuntu
    Réponses: 8
    Dernier message: 27/04/2008, 17h18
  5. Probleme cin.get() C++
    Par Sleeping Lionheart dans le forum SL & STL
    Réponses: 2
    Dernier message: 26/11/2006, 20h07

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