问题
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.
回答1:
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
来源:https://stackoverflow.com/questions/16999041/print-the-data-on-window-screen-and-then-clear-the-window-screen-before-printing