问题描述
我可以接收串口数据并且可以在窗口屏幕上打印(Tkinter top).当我再次收到串口数据时,这个新收到的串口数据应该通过擦除以前的串口数据开始在窗口屏幕上打印.这个过程有每个接收到的串行数据都会发生.我有一个代码可以在窗口上接收和打印数据,但它会在屏幕上打印所有接收到的数据,而不会擦除旧数据.
I can receive serial data and can print on the window screen(Tkinter top).when i receive serial data again, this newly received serial data should start printing on the window screen by wiping out the previous serial data.This process has to happen for every received serial data. I had a code to receive and print data on window, but it prints all the received data on the screen with out wiping the old data.
推荐答案
在这种情况下,您所要做的就是在打印新小部件之前删除小部件的先前内容.如果您有 Entry 小部件,请使用 delete
方法:
In that case, all you have to do is remove the previous content of the widget just before printing the new one. If you have an Entry widget, use the delete
method:
entry.delete(0, 'end')
# print new serial data
或者如果您有文本小部件:
Or if you have a Text widget:
text.delete(1.0, 'end')
# print new serial data
这篇关于在窗口屏幕上打印数据,然后在打印其他数据之前清除窗口屏幕.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!