'''
ARGOMENTI:

    - Widget
			Elemento dell'interfaccia utente: pulsante, barra di scorrimento, 
			campo testo, etichetta, etc. etc.

			
	- place()
			I "widget" vengono impacchettati all'interno del contenitore 
			definendone le posizioni in termini 
					assoluti (pixel) o
					relativi.

			Di solito non e' una buona norma usare place(), si preferisce usare pack() o grid(). 
			Tuttavia, in casi specifici e/o particolari puo' essere utilizzato: 
			ad esempio per posizionare contenitori.

			L'attributo "anchor" puo essere "n", "ne", "e", "se", "s", "sw", "w", "nw", "center"    
''' 


	


from tkinter import *

def LabelVISred():
		lblRED.place(x=400,y=20) 
		btn_SIred.config(state="disabled")
		btn_NOred.config(state="normal")

def LabelNASred():
		lblRED.place_forget()
		btn_SIred.config(state="normal")
		btn_NOred.config(state="disabled")

def LabelVISgreen():
		lblGREEN.pack()
		btn_SIgreen.config(state="disabled")
		btn_NOgreen.config(state="normal")

def LabelNASgreen():
		lblGREEN.pack_forget()
		btn_SIgreen.config(state="normal")
		btn_NOgreen.config(state="disabled")




fin = Tk()
fin.geometry("600x300+100+300")
fin.title("Applicazione")

#------------------------------------------------- widget
# etichette posizionate in modo assoluto e relativo
lbl1 = Label(text="Pos. Assoluto, (20;30)", bg="white").place(x=20,y=30)  
lbl2 = Label(text="Pos. Assoluto, (20;50)", bg="white").place(x=20,y=50) 
lbl3 = Label(text="Pos. Assoluto, (420;180)", bg="white").place(x=420,y=180) 
lbl4 = Label(text="Pos. Relativo CENTER, (0.5;0.5)", bg="white").place(relx=0.5, rely=0.5, anchor="center") 
lbl5 = Label(text="Pos. Relativo, (0.5;0.4)", bg="white").place(relx=0.5, rely=0.4) 
lbl6 = Label(text="Pos. Relativo, (0.9;0.9)", bg="white").place(relx=.9, rely=.9) 
lbl7 = Label(text="Pos. Relativo NE, (0.1;0.9)", bg="white").place(relx=.1, rely=.9 , anchor="ne") 
lbl8 = Label(text="Pos. Relativo SW, (0.1;0.8)", bg="white").place(relx=.1, rely=.8 , anchor="sw") 


# metodi place() e place_forget()
# -------------------------------
lblRED = Label(text="Pos. Assoluto, (400;20)", bg="red", fg="white")
lblRED.place(x=400,y=20) 
btn_SIred = Button(text="Label SI", state="disabled", command=LabelVISred)
btn_SIred.place(x=400, y=40)  
btn_NOred = Button(text="Label NO", command=LabelNASred)
btn_NOred.place(x=400, y=70)  

# metodi pack() e pack_forget()
# ------------------------------
# notare che al primo "pack_forget" i pulsanti si spostano,
# ai successivi "pack" per l'etichetta, la label viene visualizzata in "terza posizione",
# cioe' dopo i due pulsanti che sono stati visualizzati con il metodo "pack" 
lblGREEN = Label(text="PACK", bg="green", fg="white")
lblGREEN.pack() 
btn_SIgreen = Button(text="Label SI", state="disabled", command=LabelVISgreen)
btn_SIgreen.pack() 
btn_NOgreen = Button(text="Label NO", command=LabelNASgreen)
btn_NOgreen.pack()


fin.mainloop()









