标题 想用python的ttkbootstrap库做一个待办助手,但是卡在按下完成后文本框刷新上咋办?!
#导库
import tkinter as tk
import tempfile,time
from tkinter.messagebox import *
import sys
import math
import ttkbootstrap as ttk
def JieShu(): #结束事件
result = showwarning('警告', '确认关闭待办助手?')
sys.exit(0)
home.destroy()
#待办列表
daiban={123:-1,321:1}
def shuaxin():
home.update()
def ztsx(a):
daiban[a]=daiban[a]*-1
home.update()
# print(daiban)
home=ttk.Window(themename="journal")#想要切换主题,修改theme值即可,有以下这么多的主题,自己尝试吧:['vista', 'classic', 'cyborg', 'journal', 'darkly', 'flatly', 'clam', 'alt', 'solar', 'minty', 'litera', 'united', 'xpnative', 'pulse', 'cosmo', 'lumen', 'yeti', 'superhero', 'winnative', 'sandstone', 'default']
home.tk.call('wm', 'iconphoto', home._w, ttk.PhotoImage(file='tb.png')) #呜呜呜,难受,这东西设置图标有Bug
home.geometry('500x500')
home.attributes("-alpha",0.9)
home.title("待办助手v1.0")
home.resizable(width=True, height=True)
# home.overrideredirect(False)
def a(): #本来想搞自适应的.....太难了,算了算了
home.update()
return int(math.pow(home.winfo_height()+home.winfo_width(),1/2))
home.wm_attributes('-topmost',1)
# home.attributes('-toolwindow', True)
home.protocol("WM_DELETE_WINDOW", JieShu) #结束事件
# home.config(background = "white") #自从学费了ttkbootstrap库,就爽了~
top = ttk.Frame(home, width=home.winfo_height(), height=10, relief='groove', borderwidth=0)
top.pack()
frame=ttk.Frame(home, width=250, height=10, borderwidth=0)
for i in daiban:
frame2=ttk.Frame(frame, width=250, height=10, borderwidth=0)
if(daiban[i]==1):
aa=ttk.Text(frame2, height=1, width=21, font=('微软雅黑', 10, 'overstrike'))
aa.insert('0.0', i)
button = ttk.Button(frame2, text='未完成', command=ztsx(i))
else:
aa=ttk.Text(frame2, height=1, width=20, font=('微软雅黑', 10, 'bold'))
aa.insert('0.0', i)
button = ttk.Button(frame2, text='已完成', command=ztsx(i))
aa.configure(state="disabled")
aa.pack()
button.pack()
frame2.pack()
frame.pack()
home.bind('home.window_resize',shuaxin)
lb = ttk.Label(top, text="欢迎来到待办助手~=,font=('微软雅黑',int(a()*0.5-5)))
lb.pack()
home.mainloop()
现在查了一堆CSDN,实在没办法了,发个帖!