c’est root
root=Tk()
C’est le script complet
#!/usr/bin/python -> page-de fichier formulaire.py python
# -*- coding: utf-8 -*- -> formulaire d'inscription Formulaire sqlite3
# Python 3.11.1 -> jacky michaud
# import string
# import tkinter as tk
import sys,io,os
from tkinter import *
# from tkinter import messagebox
from tkinter import ttk, messagebox
from tkinter.messagebox import *
import sqlite3
class Formulaire:
def __init__(self, root):
self.root = root
self.root.title("Formulaire du jacky")
self.root.geometry("1500x760+15+10")
# les variables
self.id = StringVar() # id
self.titre = StringVar() # Titre
self.nom = StringVar() # Nom
self.prenom = StringVar() # Prenom
self.mail = StringVar() # Mail
self.telephone = StringVar() # Telephone
self.date = StringVar() # Date
self.cotisation = StringVar() # cotisation
self.ville = StringVar() # ville
self.code_postal = StringVar() # code_postal
self.adresse = StringVar() # adresse
# champs du formulaire
frame1 = Frame(self.root, bg="cyan")
frame1.place(x=450, y=120, width=700, height=440)
title = Label(frame1, text="Lecture fiche", font=("ink Free", 25, "bold"), bg="cyan", fg="red").place(x=140, y=20)
# Id
aff_id =Label(frame1, text= "Id", font = ("times new roman",15, "bold"), bg= "cyan", fg= "black").place(x=50, y=40)
id_txt = Entry(frame1, textvariable = self.id, font= ("times new roman", 15),bg ="lightgrey")
id_txt.place(x=50,y=70,width=80)
# id_txt.focus_set()
# titre
aff_titre =Label(frame1, text= "Titre", font=("times new roman",15, "bold"), bg="cyan", fg= "black").place(x=370, y=40)
titre_txt = Entry(frame1, textvariable= self.titre, font=("times new roman", 15),bg ="lightgrey")
titre_txt.place(x=370,y=70,width=80)
# nom
aff_nom =Label(frame1, text= "Nom", font=("times new roman",15, "bold"), bg="cyan", fg= "black").place(x=50, y=100)
nom_txt = Entry(frame1, textvariable= self.nom, font= ("times new roman", 15),bg ="lightgrey")
nom_txt.place(x=50,y=130,width=250)
#nom_var = tk.StringVar(self.nom)
#nom_txt = Entry(frame1, textvariable=nom_var)
#nom_txt.pack()
# prenom
aff_prenom =Label(frame1, text= "Prénom", font=("times new roman",15, "bold"), bg="cyan", fg= "black").place(x=370, y=100)
prenom_txt = Entry(frame1, textvariable= self.prenom, font=("times new roman", 15),bg ="lightgrey")
prenom_txt.place(x=370,y=130,width=250)
# mail
aff_mail =Label(frame1, text= "E-mail", font=("times new roman",15, "bold"), bg="cyan", fg= "black").place(x=50, y=160)
mail_txt = Entry(frame1, textvariable= self.mail, font= ("times new roman", 15),bg ="lightgrey")
mail_txt.place(x=50,y=190,width=250)
# telephone
aff_telephone =Label(frame1, text= "Téléphone", font= ("times new roman",15, "bold"), bg="cyan", fg= "black").place(x=370, y=160)
telephone_txt = Entry(frame1, textvariable= self.telephone, font=("times new roman", 15),bg ="lightgrey")
telephone_txt.place(x=370,y=190,width=250)
# date
aff_date =Label(frame1, text= "Date", font=("times new roman",15, "bold"), bg="cyan", fg= "black").place(x=50, y=220)
date_txt = Entry(frame1, textvariable= self.date, font= ("times new roman", 15),bg ="lightgrey")
date_txt.place(x=50,y=250,width=250)
# cotisation
aff_cotisation =Label(frame1, text= "Cotisation", font= ("times new roman",15, "bold"), bg="cyan", fg= "black").place(x=370, y=220)
cotisation_txt = Entry(frame1, textvariable= self.cotisation, font= ("times new roman", 15),bg ="lightgrey")
cotisation_txt.place(x=370,y=250,width=250)
# code_postal
aff_code_postal =Label(frame1, text= "Code_postal", font= ("arial",15, "bold"), bg="cyan", fg= "black").place(x=50, y=280)
code_postal_txt = Entry(frame1, textvariable= self.code_postal, font= ("times new roman", 15),bg ="lightgrey")
code_postal_txt.place(x=50,y=310,width=250)
# adresse
aff_adresse =Label(frame1, text="Adresse", font= ("times new roman",15, "bold"), bg="cyan", fg= "black").place(x=370, y=280)
adresse_txt = Entry(frame1, textvariable= self.adresse, font= ("times new roman", 15),bg ="lightgrey")
adresse_txt.place(x=370,y=310, width=300, height=90)
# ville
aff_ville =Label(frame1, text="Ville", font= ("arial",15, "bold"), bg= "cyan", fg= "black").place(x=50, y=340)
ville_txt = Entry(frame1, textvariable= self.ville, font= ("times new roman", 15),bg ="lightgrey")
ville_txt.place(x=50,y=370,width=250)
# les boutons de validation et connexion
# btn = Button(frame1, text="Creer", cursor="hand2", command=self.creer, font=("times new roman", 15, "bold"), bg="cyan", fg="black").place(x=250, y=430, width=250)
# connexion
btn1 = Button(frame1, text="Affichage", command=self.afficherRechertat, cursor="hand2", font=("times new roman", 15, "bold"), bg="cyan", fg="black").place(x=500, y=50, width=150)
############################
def afficherRechertat(self):
con = sqlite3.connect("creerinscript.db")
cur = con.cursor()
cur.execute("select * from formordi ")
rows = cur.fetchall()
for row in rows:
self.id = row[0] # id
self.titre = row[1] # titre
self.nom = row[2] # Nom
self.prenom = row[3] # Prenom
self.mail = row[4] # mail
self.telephone = row[5] # telephone
self.date = row[6] # Date
self.cotisation = row[7] # cotisation
self.ville = row[8] # ville
self.code_postal = row[9] # code_postal
self.adresse = row[10] # Adresse
self.information()
messagebox.showinfo("Succes", "Enregistrement afficher")
self.reini()
con.commit()
con.close()
# information affichage
def information(self):
#cursors_row = self.tabl_resul.focus()
#contents = self.row = (cursors_row)
#row =contents["values"]
self.id, # id
self.titre, # Titre
self.nom, # Nom
self.prenom, # Prenom
self.mail, # mail
self.telephone, # Telephone
self.date, # Date
self.cotisation, # cotisation
self.ville, # ville
self.code_postal, # code_postal
#self.adresse.delete("1.0", END) # Adresse
self.adresse, # Adresse
# reinitialisation
def reini(self):
self.id="" # id
self.titre="" # Titre
self.nom="" # Nom
self.prenom="" # Prenom
self.mail="" # mail
self.telephone="" # Telephone
self.date="" # Date
self.cotisation="" # cotisation
self.ville="" # ville
self.code_postal="" # code_postal
self.adresse="" # Adresse
# def fenetre_login(self):
# self.root.destroy()
# import Login
self.afficherRechertat()
self.information()
self.reini()
root=Tk()
obj =Formulaire(root)
root.mainloop()