Hello everyone,
I am still in my early days on python. I have an arraw with a Label, an Entry and a combobox in one row. I want to write a method that copies this row to the end of the array with the insert button. I think it should be simple; but I can’t do it. Here is the table and the code. Can someone help me?
Importer le module tkinter
import tkinter as tk
from tkinter import Tk, ttk, Menu, Frame
from tkinter.constants import COMMAND, GROOVE
from tkinter.ttk import Entry
class Tableau(tk.Tk):
“”“Tableau”""
def __init__(self,*args, **kwargs):
super().__init__(*args, **kwargs)
Texte_Titre = '#AA6D39'
Police_Paragraphe = ('Arial', 11)
bg_bleu = '#FFD1AA'
# set the window properties
self.title("Tableau")
self.geometry("580x250")
self.resizable(width=False, height=False)
self.Propriete_cadre = tk.Frame(self, width=150,height=200,bd=5,relief=GROOVE)
self.Propriete_cadre.grid(row=0, column=0,columnspan=6)
self.A1 = tk.Label(self.Propriete_cadre,bg=bg_bleu,bd=2,relief=GROOVE,padx=10,
height=2, text='0',font=Police_Paragraphe,fg=Texte_Titre)
self.A1.grid(row=0, column=0)
self.B1 = tk.Label(self.Propriete_cadre,bg=bg_bleu,bd=2,relief=GROOVE,padx=10,
height=2, text='Type de Donnée',font=Police_Paragraphe,fg=Texte_Titre)
self.B1.grid(row=0, column=1)
self.C1 = tk.Label(self.Propriete_cadre,bg=bg_bleu,bd=2,relief=GROOVE,padx=10,
height=2, text='Quantité',font=Police_Paragraphe,fg=Texte_Titre)
self.C1.grid(row=0, column=2)
self.D1 = tk.Label(self.Propriete_cadre,bg=bg_bleu,bd=2,relief=GROOVE,padx=10,
text='Prefixe\ndes données',font=Police_Paragraphe,fg=Texte_Titre)
self.D1.grid(row=0, column=3)
self.E1 = tk.Label(self.Propriete_cadre,bg=bg_bleu ,bd=2,relief=GROOVE,width=10,
text='Valeurs\nrelatives',font=Police_Paragraphe,fg=Texte_Titre)
self.E1.grid(row=0, column=4)
self.A2 = tk.Label(self.Propriete_cadre,bg=bg_bleu ,bd=2,relief=GROOVE,padx=10,
height=1, text='1',font=Police_Paragraphe,fg=Texte_Titre)
self.A2.grid(row=1, column=0)
TypeDonnees = ['(A)Anglais', '(R)Culture_Générale', '(B)Biologie', '(S)Sciences']
self.B2 = ttk.Combobox(self.Propriete_cadre, width=12, values=TypeDonnees, font=Police_Paragraphe)
self.B2.current(1)
self.B2.grid(row=1, column=1)
QuantiteNo = ['1','2','3','4','7','8','9']
self.C2 = ttk.Combobox(self.Propriete_cadre, width=8,values=QuantiteNo, font=Police_Paragraphe)
self.C2.current(0)
self.C2.grid(row=1, column=2)
Prefixe = ['Ang', 'Cul', 'Bio', 'Sci']
self.D2 = ttk.Combobox(self.Propriete_cadre, width=8, values=Prefixe, font=Police_Paragraphe)
self.D2.current(1)
self.D2.grid(row=1, column=3)
self.E2 = tk.Entry(self.Propriete_cadre, width=10, font=Police_Paragraphe)
self.E2.grid(row=1, column=4)
# Ajouter des donnees
self.BoutonsClassiques = tk.Frame(self, width=50,height=550)
self.BoutonsClassiques.grid(row=8, column=7)
self.BoutonInserer = tk.Button(self.BoutonsClassiques,text='Insérer',
font=Police_Paragraphe,padx=22)
self.BoutonInserer.grid(row=3,column=0)
if name == ‘main’:
root = Tableau()
root.mainloop()