Skip to content

Instantly share code, notes, and snippets.

@fmaida

fmaida/main.py Secret

Last active December 8, 2016 21:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fmaida/ca8e43e1a75ab88e8ad6093ca42598cc to your computer and use it in GitHub Desktop.
Save fmaida/ca8e43e1a75ab88e8ad6093ca42598cc to your computer and use it in GitHub Desktop.
Tkinter come fosse antani
from tkinter import *
class MiaLabel(Label):
@property
def text(self):
return self.cget("text")
@text.setter
def text(self, p_valore):
self.config(text=p_valore)
root = Tk()
my_label = MiaLabel(root, text="Per ora ho il testo sbagliato...")
my_button = Button(root, text="Io sono un pulsante")
my_label.pack()
my_button.pack()
# Bene, ora voglio verificare il testo della label...
print(my_label.text)
# Uffa! Voglio cambiare il testo alla label!
my_label.text = "Ciao a tutti belli e brutti"
root.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment