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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
| -*- coding:utf-8 -*-
from Tkinter import *
import bwidget
import time
import threading
import shelve
import sys
police0 = ('Verdana', 9)
police1 = ('Verdana', 9, 'bold')
police2 = ('Verdana', 10, 'bold')
police3 = ('Verdana', 11, 'bold')
logiciel = "SUIVI D'ATELIER 1.0"
def geoliste(g):
r=[i for i in range(0,len(g)) if not g[i].isdigit()]
return [int(g[0:r[0]]),int(g[r[0]+1:r[1]]),int(g[r[1]+1:r[2]]),int(g[r[2]+1:])]
def centrefenetre(fen):
fen.update_idletasks()
l,h,x,y=geoliste(fen.geometry())
fen.geometry("%dx%d%+d%+d" % (l,h,(fen.winfo_screenwidth()-l)//2,(fen.winfo_screenheight()-h-30)//2))
def save_all():
liste1 = [e1.get(), e2.get(), e3.get()]
liste2 = [r1.get(), r2.get(), r3.get()]
liste3 = [e4.get(), e5.get(), e6.get()]
cle1 = e1.get()
bdd0 = shelve.open('dossier.dbm')
bdd0[cle1] = liste1 + liste2 + liste3
bdd0.close()
def apl_dossier():
bdd1 = shelve.open('dossier.dbm')
clebdd1= bdd1.keys()
clebdd1.sort()
nom1 = tuple(clebdd1)
bdd1.close()
def act0():
bdd1 = shelve.open('dossier.dbm')
select = nom.get()
datadossier = bdd1[select]
bdd1.close()
e1.delete(0,END)
e2.delete(0,END)
e3.delete(0,END)
e4.delete(0,END)
e5.delete(0,END)
e6.delete(0,END)
e1.insert(0, datadossier[0])
e2.insert(0, datadossier[1])
e3.insert(0, datadossier[2])
if datadossier[3] == 1:
chk1.select()
if datadossier[4] == 1:
chk2.select()
if datadossier[5] == 1:
chk3.select()
e4.insert(0, datadossier[6])
e5.insert(0, datadossier[7])
e6.insert(0, datadossier[8])
t0.destroy()
t0 = Toplevel()
t0.title("Ouvrir un dossier")
nom = bwidget.ComboBox(t0, values = nom1, width = 30, font = police0)
nom.grid(row = 0, column = 0, padx = 10, pady = 5, sticky = W)
valid = Button(t0, text = 'Ouvrir', font = police0, command = act0)
valid.grid(row = 1, column = 0, padx = 10, pady = 5, sticky = W)
stop = Button(t0, text = 'Abandon', font = police0, command = t0.destroy)
stop.grid(row = 1, column = 1, padx = 10, pady = 5, sticky = W)
############## CREATION DU PROGRAMME PRINCIPAL #################
root = Tk()
root.title(logiciel)
centrefenetre(root)
root.geometry('800x300')
root.resizable(width=False, height=False)
#Création date et des cadres et autres widgets principaux
#Cadre
cadre0 = LabelFrame(root, text = 'Cadre1', font = police2, fg = 'darkblue')
cadre0.place(x = 5, y = 5)
cadre1 = LabelFrame(root, text = 'Cadre2', font = police2, fg = 'darkblue')
cadre1.place(x = 5, y = 50)
cadre2 = LabelFrame(root, text = "Cadre3", font = police2, fg = 'darkblue')
cadre2.place(x = 5, y = 100)
#Bouton
valid = Button(root, text = 'Enregistrer tout', font = police0, command = save_all)
valid.place(x = 5, y = 250)
ouvre = Button(root, text = 'Ouvrir', font = police0, command = apl_dossier)
ouvre.place(x = 200, y = 250)
stop = Button(root, text = 'Fermer', font = police0, command = root.quit)
stop.place(x = 300, y = 250)
#Cadre0
info1 = Label(cadre0, text = "Entrée1:", font = police0)
info1.grid(row = 0, column = 0, sticky = E)
e1 = Entry(cadre0, font = police0)
e1.grid(row = 0, column = 1, padx = 5, pady = 3, sticky = E)
info2 = Label(cadre0, text = "Entrée2:", font = police0)
info2.grid(row = 0, column = 2, sticky = E)
e2 = Entry(cadre0, font = police0)
e2.grid(row = 0, column = 3, padx = 5, pady = 3, sticky = E)
info3 = Label(cadre0, text = "entrée3:", font = police0)
info3.grid(row = 0, column = 4, sticky = E)
e3 = Entry(cadre0, font = police0)
e3.grid(row = 0, column = 5, padx = 5, pady = 3, sticky = E)
#Cadre1
r1 = IntVar()
r2 = IntVar()
r3 = IntVar()
chk1 = Checkbutton(cadre1, text = 'Coche1', variable = r1, font = police0)
chk1.grid(row = 0, column = 0, sticky = W)
chk2 = Checkbutton(cadre1, text = 'Coche2', variable = r2, font = police0)
chk2.grid(row = 0, column = 1, sticky = W, padx = 10, pady = 2)
chk3 = Checkbutton(cadre1, text = 'Coche3', variable = r3, font = police0)
chk3.grid(row = 0, column = 2, sticky = W)
#Cadre2
info4 = Label(cadre2, text = 'Entrée4:', font = police0)
info4.grid(row = 0, column = 0, sticky = E)
info5 = Label(cadre2, text = 'Entrée5:', font = police0)
info5.grid(row = 1, column = 0, sticky = E)
info6 = Label(cadre2, text = 'Entrée6:', font = police0)
info6.grid(row = 2, column = 0, sticky = E)
e4 = Entry(cadre2, font = police0, width = 5)
e4.grid(row = 0, column = 1, padx = 5, pady = 2, sticky = E)
e5 = Entry(cadre2, font = police0, width = 5)
e5.grid(row = 1, column = 1, padx = 5, pady = 2, sticky = E)
e6 = Entry(cadre2, font = police0, width = 5)
e6.grid(row = 2, column = 1, padx = 5, pady = 2, sticky = E)
e1.focus_set()
root.mainloop() |
Partager