Hola. Soy muy nuevo en esto de la programacion en Python.
Tengo una duda sobre un codigo:
from tkinter import ttk
import tkinter as tk
class CheckbuttonForEntry(ttk.Checkbutton):
"""
Checkbutton para deshabilitar un Entry.
"""
def __init__(self, *args, **kwargs):
self._var = tk.BooleanVar(value=True)
kwargs["variable"] = self._var
self.entry = kwargs.pop("entry")
super().__init__(*args, **kwargs)
self.config(command=self.clicked)
def clicked(self):
entry.config(state=tk.NORMAL if self._var.get() else tk.DISABLED)
root = tk.Tk()
entry = ttk.Entry()
checkbutton = CheckbuttonForEntry(
text="Entry activado",
entry=entry
)
entry2 = ttk.Entry()
checkbutton2 = CheckbuttonForEntry(
text="Entry2 activado",
entry=entry2
)
checkbutton.grid(row=0,column=0)
entry.grid(row=2, column=1)
checkbutton2.grid(row=1,column=0)
entry2.grid(row=3, column=1)
root.mainloop()
* root.mainloop()
de este codigo, que sirve para que cada checkbutton habilite o deshabilite a un entry, no comprendo la parte de inicializacion de la subclase de checkbutton
def __init__(self, *args, **kwargs):
self._var = tk.BooleanVar(value=True)
kwargs["variable"] = self._var
self.entry = kwargs.pop("entry")
super().__init__(*args, **kwargs)
self.config(command=self.clicked)
si alguien pudiera explicarlo, o indicarme donde leer algo al respecto, lo agradezco.
Saludos