CODICE
# -*- coding: utf-8 -*-
import tkinter as tk
class FrmData(tk.Frame):
'''Frame contenitore per controlli definizione dati anagrafici'''
def __init__(self, mater):
self.mater = mater
super().__init__(self.mater)
# definizione controlli riga 1
frmr1 = tk.Frame(self, padx=2, pady=4)
frmr1.pack(fill='x')
self.lbl1 = tk.Label(frmr1, text='Codice: ', padx=2)
self.lbl1.pack(side='left')
self.eID = tk.Entry(frmr1, width=6)
self.eID.pack(side='left')
self.ckPersona = tk.Checkbutton(frmr1, text='Persona fisica', padx=2)
self.ckPersona.pack(side='left')
self.ckObsoleto = tk.Checkbutton(frmr1, text='Obsoleto', padx=2)
self.ckObsoleto.pack(side='left')
# definizione controlli riga 2
frmr2 = tk.Frame(self, padx=2, pady=4)
frmr2.pack(fill='x')
self.lbl2 = tk.Label(frmr2, text='Cognome/Rag. Sociale :', padx=2)
self.lbl2.pack(side='top', anchor='w')
self.eCognome = tk.Entry(frmr2)
self.eCognome.pack(side='bottom',fill='x')
# definizione controlli riga 3
frmr3 = tk.Frame(self, padx=2, pady=4)
frmr3.pack(fill='x')
frmr3_s1 = tk.Frame(frmr3, padx=2)
frmr3_s1.pack(side='left', fill='x', expand=True)
self.lbl3 = tk.Label(frmr3_s1, text='Nome :', padx=2)
self.lbl3.pack(side='top', anchor='w')
self.eNome = tk.Entry(frmr3_s1)
self.eNome.pack(side='bottom', fill='x')
frmr3_s2 = tk.Frame(frmr3, padx=4)
frmr3_s2.pack(side='right')
self.lbl4 = tk.Label(frmr3_s2, text='Nato il :', padx=2)
self.lbl4.pack(side='top', anchor='w')
self.eNato = tk.Entry(frmr3_s2, width=20)
self.eNato.pack(side='bottom')
# definizione controlli riga 4
frmr4 = tk.Frame(self, padx=2, pady=4)
frmr4.pack(fill='x')
frmr4_s1 = tk.Frame(frmr4, padx=2)
frmr4_s1.pack(side='left', fill='x', expand=True)
self.lbl5 = tk.Label(frmr4_s1, text='Luogo nascita :', padx=2)
self.lbl5.pack(side='top', anchor='w')
self.eLuogo = tk.Entry(frmr4_s1)
self.eLuogo.pack(side='bottom', fill='x')
frmr4_s2 = tk.Frame(frmr4, padx=4)
frmr4_s2.pack(side='right')
self.lbl6 = tk.Label(frmr4_s2, text='Cod. Fiscale/P.ta IVA :', padx=2)
self.lbl6.pack(side='top', anchor='w')
self.eCodFisc = tk.Entry(frmr4_s2, width=20)
self.eCodFisc.pack(side='bottom')
class FRMAnagCommand(tk.Frame):
'''Fornisce un pannello di comando per la gestione anagrafica'''
def __init__(self, mater):
self.mater = mater
super().__init__(self.mater)
self.configure(padx=4, pady=4)
self.imgNuovo = tk.PhotoImage(file='risorse/nuova.png')
self.btNuovo = tk.Button(self,
compound='left',
image=self.imgNuovo,
text='Nuova',
pady=4,
padx=4
)
self.btNuovo.pack(side='left', expand=True, fill='x')
self.imgModifica = tk.PhotoImage(file='risorse/modifica.png')
self.btModifica = tk.Button(self,
compound='left',
image=self.imgModifica,
text='Modifica',
pady=4,
padx=4
)
self.btModifica.pack(side='left', expand=True, fill='x')
self.imgSalva = tk.PhotoImage(file='risorse/salva.png')
self.btSalva = tk.Button(self,
compound='left',
image=self.imgSalva,
text='Salva',
pady=4,
padx=4
)
self.btSalva.pack(side='left', expand=True, fill='x')
self.imgCancella = tk.PhotoImage(file='risorse/cancella.png')
self.btAnnulla = tk.Button(self,
compound='left',
image=self.imgCancella,
text='Annulla',
pady=4,
padx=4
)
self.btAnnulla.pack(side='left', expand=True, fill='x')
self.imgCerca = tk.PhotoImage(file='risorse/cerca.png')
self.btCerca = tk.Button(self,
compound='left',
image=self.imgCerca,
text='Cerca',
pady=4,
padx=4
)
self.btCerca.pack(side='left', expand=True, fill='x')
self.imgEsci = tk.PhotoImage(file='risorse/esci.png')
self.btEsci = tk.Button(self,
compound='left',
image=self.imgEsci,
text='Esci',
pady=4,
padx=4
)
self.btEsci.pack(side='left', expand=True, fill='x')
class GUIAnag(tk.Tk):
'''Finestra principale applicazione : gestione dei dati anagrafici'''
def __init__(self):
super().__init__()
self.title('Anagrafiche')
self.sfdata = FrmData(self)
self.sfdata.pack(fill='x')
self.sfcommand = FRMAnagCommand( self)
self.sfcommand.pack(fill='x')
# Un menu per Maresama
barra_menu = tk.Menu(self)
self.config(menu=barra_menu)
menu_anag = tk.Menu(barra_menu)
# definizione delle immagini
self.imgNuovo = tk.PhotoImage(file='risorse/nuova.png')
self.imgModifica = tk.PhotoImage(file='risorse/modifica.png')
self.imgSalva = tk.PhotoImage(file='risorse/salva.png')
self.imgCancella = tk.PhotoImage(file='risorse/cancella.png')
self.imgCerca = tk.PhotoImage(file='risorse/cerca.png')
self.imgEsci = tk.PhotoImage(file='risorse/esci.png')
self.imgAnag = tk.PhotoImage(file='risorse/nuovo.png')
barra_menu.add_cascade(label='Anagrafiche',
menu=menu_anag,
compound='left',
image=self.imgAnag)
menu_anag.add_command(label='Nuova',
compound='left',
image=self.imgNuovo)
menu_anag.add_separator()
menu_anag.add_command(label='Modifica',
compound='left',
image=self.imgModifica)
menu_anag.add_command(label='Salva',
compound='left',
image=self.imgSalva)
menu_anag.add_command(label='Annulla',
compound='left',
image=self.imgCancella)
menu_anag.add_separator()
menu_anag.add_command(label='Cerca',
compound='left',
image=self.imgCerca)
menu_anag.add_separator()
menu_anag.add_command(label='Esci',
compound='left',
image=self.imgEsci)
menu_anag.add_separator()
class GUISec(tk.Toplevel):
'''Finestra secondaria di test'''
def __init__(self, root):
super().__init__(root)
self.title('Seconda finestra')
self.sfdata = FrmData(self)
self.sfdata.pack(side='top', fill='x')
# *** AVVIO APPLICAZIONE ***
if __name__ == '__main__':
princ = GUIAnag()
#sec = GUISec(princ)
princ.mainloop()