tkinter 奇妙的突然无法修改Text对象问题

来源:互联网 发布:上海游安网络 编辑:程序博客网 时间:2024/05/24 06:53

问题描述:

使用tkinter的Text对象建立一个self.text_screen对象可以通过如下代码的前半部分刷新为“是否打印清单”,但后面函数却始终无法二次刷新。(确实执行了注册的函数)详细如下:(pycharm)
def print_deal_list_state(self):        self.text_screen['state']=NORMAL        self.text_screen.delete('1.0',END)        self.text_screen.insert('1.0',('\n\n\t是否打印交易清单?'))        self.text_screen['state']=DISABLED        self.btn_deposit['state']=DISABLED        self.btn_transfer['state']=DISABLED        self.btn_withdraw['state']=DISABLED        def ending_thanking():            self.text_screen['state']=NORMAL            self.text_screen.delete('1.0',END)            self.text_screen.insert('1.0','\n\n\t谢谢惠顾!')            #time.sleep(2)            self.main_state()        def press_ok():            #print('hi?')            self.text_screen['state']=NORMAL            self.text_screen.delete('1.0',END)            self.text_screen.insert('1.0','\n\n\t请稍等,打印中...')            # time.sleep(2)#wait 2 second to simulate the process            self.text_screen.delete('1.0',END)            self.text_screen.insert('1.0','\n\n\t打印完毕')            ending_thanking()        def press_cancel():            ending_thanking()        self.btn_ok.configure(command=lambda *args:self.press_ok())        self.btn_cancel.configure(command=lambda *args:self.press_cancel())

解决方法:

同一个调用里,两次对Text插件进行插入删除,中间没有更新
self.text_screen.update()
0 0
原创粉丝点击