Tkinter show label after function called when label should di

325 Views Asked by At

Tkiner display the label after callback function. but i display label in the top.

def records():
    lbl = tk.Label(recordWindow, text="recording")
    lbl.grid()
    Audio1()
 
btn = tk.Button(recordWindow, text="click to record",command=records)
btn.grid()

in this Audio1 function call and display the label. I need display the label and call back the function.

I Need to display the "recording" and run the audio1() function. but what happened is after running the audio1() function it display the "recording" label

1

There are 1 best solutions below

0
On BEST ANSWER

I'm not sure if I understand the issue entirely, but here is a shot at it. I added row and column parameters to the grid() method, so that lbl isn't at the top. I'm not certain of what label you want the Audio1 function to display. Perhaps you want it to flash on and off the lbl.

def Audio1():
    global lbl
    if lbl.winfo_ismapped():
        lbl.grid_forget()
    else:
        lbl.grid()
    root.after(1000, Audio1)  # assumes your window is named root

def records():
    global lbl
    lbl.grid(row=1, column=0)
    Audio1()

lbl = tk.Label(recordWindow, text="recording") 
btn = tk.Button(recordWindow, text="click to record",command=records)
btn.grid(row=0, column=0)