-
-
Save fmaida/ca8e43e1a75ab88e8ad6093ca42598cc to your computer and use it in GitHub Desktop.
Tkinter come fosse antani
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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