Hi, I'm trying to put sleep action on my program, but I would like program to sleep after I (as user)click and when he changes the picture on the button. and I don't know where to put it.
please help

this is example of code :)

import tkinter as tk
from functools import partial
def klik(n):
root = tk.Tk()
frame1 = tk.Frame(root)
frame1.pack(side=tk.TOP, fill=tk.X)
karirano = tk.PhotoImage(file="kari.GIF")
s = list(tk.PhotoImage(file="%d.GIF" % (i+1)) for i in range(4))
button = list()
for i in range(4):
    button.append(tk.Button(frame1, image=karirano, command=partial(klik, i)))

Edited 4 Years Ago by Vkitor: n/a

Why do you want your program to sleep ? You program does nothing but wait between clicks, isn't that sufficient ? If you add a sleep() somewhere, the gui will be unresponsive while the program sleeps.

Edited 4 Years Ago by Gribouillis: n/a

I'd like to make that when 1 or 2 button's are pressed, others cant be pressed for some time

I tried, but when I started program, I got this message:

button[n].config(state= disabled)
NameError: global name 'disabled' is not defined

NameError: global name 'DISABLED' is not defined

Edited 4 Years Ago by Vkitor: n/a

ok, but I want to disable all buttons for 5sec, and then enable them all again. how can i do that?

Edited 4 Years Ago by Vkitor: n/a

? what

Set an after timer event five seconds from disabling buttons to re-enable the buttons.

This article has been dead for over six months. Start a new discussion instead.