Show and hide text in a Button Tkinter

0

I'm trying to place a button with tkinter that does not appear its text placed on it until you click on it. I am trying to do it in the following way but it does not work for me the buttons come out the same in white. I have doubts in the function arguments inside the button but I'm not sure what I need to do

def callback_btn(btn,text):
        btn.configure(text=text)

def dibujando_tab(matriz, numero_filas, numero_columnas, frame):
    for row_index in range(numero_filas):
        Grid.rowconfigure(frame, row_index, weight=2)
        for col_index in range(numero_columnas):
            Grid.columnconfigure(frame, col_index, weight=2)
            texto=str(matriz[row_index][col_index][(row_index, col_index)][::]).replace("[","")
            for char in n:
                texto = texto.replace(char,"")
            btn = Button(frame)
            btn.configure( command = lambda: callback_btn(btn, texto)) 
            btn.grid(row=row_index, column=col_index, sticky=N+S+E+W)  
    
asked by Juan J. Mart 21.11.2018 в 15:24
source

1 answer

0

As I do not know with what data the call to drawing_tab is made, I simplified the problem and left it in the following way:

from tkinter import Tk, Button

def callback_btn(btn,text):
  btn.configure(text=text)

    v = Tk()
    v.title("V")
    v.geometry("200x100+100+100")

    texto = "HICISTE CLIC"
    boton = Button(v, text="", command=lambda: callback_btn(boton, texto))
    boton.place(x=50, y=30, width=100, height=30)

I made the invocation to the callback_btn function, and the result is as expected.

I remember that at some point I had a similar problem, in which some aspect changes were not refreshed on the controls, for that, I had to use the update () function. Although for the case of the example I made it is not necessary, it would be enough to use v.update () after modifying the button.

    
answered by 27.12.2018 в 17:04