时间脉冲tkinter python

2024-06-26 07:25:55 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个改变图像的代码。 我用过。但我想通过数据输入来调整时间(3000毫秒)。 我该怎么做

muted3 = False
def mute_music3():
    global muted3
    if muted3:
        volumeKnop3.configure(image=volumePhoto3)
        muted3 = False
        root.after(3000, mute_music3)
    else:
        volumeKnop3.configure(image=mutePhoto3)
        muted3 = True

root.after(0, mute_music3)


mutePhoto3 = PhotoImage(file="C:\\Users\\evanh\\Desktop\\buttonimage\\Time_Done.png")
volumePhoto3 = PhotoImage(file="C:\\Users\\evanh\\Desktop\\buttonimage\\Time_Not_Done.png")

volumeKnop3 = Button(image=volumePhoto3, command=mute_music3, background="white", activebackground="White", border=0)
volumeKnop3_window = canvas.create_window(30, 200, anchor="nw", window=volumeKnop3)

Tags: imagefalseconfigurerootwindowusersfileafter