I am beginner to python and stucked with something in tkinter. Below is the code that application receives GPS data from my bluetooth module and I want to output "data" to my Text widget "outputtext".
import serial
from tkinter import *
root = Tk()
serialPort = serial.Serial(port='COM8', baudrate=9600, timeout=0, parity=serial.PARITY_EVEN, stopbits=1)
size = 10240
def myClick():
while serialPort:
data = serialPort.readline(size)
if data:
print(data)
outputtext.insert('1.0', data)
outputtext = Text(root)
outputtext.pack()
myButton = Button(root, text="Retrieve Bluetooth Data!", command=myClick)
myButton.pack()
root.mainloop()
print is working perfectly however I am not able to output "data" to "outputtext". Application does not respond immediately after clicking "myButton". This might be due to huge data I receive (NMEA sentence every second). Maybe I should use buffer or something. Any help would be highly appreciated.