当我按下按钮时它返回错误好像没有点击

问题描述

在继续点击或第一次点击时经常出现此问题。 它与循环迭代器有关吗?? 它的来源是否像普通的复选按钮一样应用? 我当然使用这个源 img 按钮

下面是我复制粘贴的代码,帮助你回答我
谢谢!

from tkinter import ttk
from tkinter import *
import itertools as it
import tkinter as tk
root = Tk()
root.geometry("1080x1000+200+50")
root.resizable(False,False)
    
class framess:
    def toggle11():
        srtchkarr[0]['image'] = next(images)
    
    def toggle12(e):
        srtchkarr[0]['image'] = next(images)
    
    def toggle21():
        srtchkarr[1]['image'] = next(images)
    
    def toggle22(e):
        srtchkarr[1]['image'] = next(images)
    
    def toggle31():
        srtchkarr[2]['image'] = next(images)
    
    def toggle32(e):
        srtchkarr[2]['image'] = next(images)
            
image_up = tk.PhotoImage(
    file='checkbuttonnormal.png')
image_down = tk.PhotoImage(
    file='checkbuttonclicked.png')
images = it.cycle([image_down,image_up])
    
startchk1 = tk.Button(root,text="startchk1",border=0,relief="flat",image=image_up,command=framess.toggle11)
startchk1.config(cursor='circle')
startchk1tit = Label(root,text=" click!",anchor="w",width=5,height=2,font=(
    'aial',18),background="#f0f0f0",border=0)
startchk1tit.config(cursor='circle')
startchk1tit.bind('<Button-1>',framess.toggle12)
startchk1.place(width=21,height=21,x=340,y=368)
startchk1tit.place(x=361,y=354)
    
startchk2 = tk.Button(root,command=framess.toggle21)
startchk2.config(cursor='circle')
startchk2tit = Label(root,text=" click2!",border=0)
startchk2tit.config(cursor='circle')
startchk2tit.bind('<Button-1>',framess.toggle22)
startchk2.place(width=21,x=440,y=368)
startchk2tit.place(x=461,y=354)
    
startchk3 = tk.Button(root,command=framess.toggle31)
startchk3.config(cursor='circle')
startchk3tit = Label(root,text=" click3!",border=0)
startchk3tit.config(cursor='circle')
startchk3tit.bind('<Button-1>',framess.toggle32)
startchk3.place(width=21,x=540,y=368)
startchk3tit.place(x=561,y=354)
srtchkarr = [startchk1,startchk2,startchk3]
root.mainloop()

图片

enter image description here

enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)