0

Hy, I am trying to make a GUI with tkinter. which gets data from a microcontroller... everything works fine. at the begining it shows 0.00 at the center... but when i click start it shows real time data. but possition is changed to upper.... is there any solution for this? i want it in center...

def changeLabel():
        while ser.in_waiting:
            rawdata=ser.readline()
            #ser.close()
            print(rawdata)
            textlabel.configure(text=rawdata,font=('Segment7Standard',20,'bold'))
        master.after(500, changeLabel)
master=Tk()
master.geometry("500x500")
master.title('Developed By Rahul Mitra')
textlabel=Label(master,width=10,height=4,foreground="yellow",background="black",text="0.00", font=('times',20,'bold'))
textlabel.grid(row=1, column=1,sticky=SW)

After clicking start

Before clicking "Start"

  • Read [While Loop Locks Application](https://stackoverflow.com/questions/28639228/python-while-loop-locks-application) – stovfl Nov 16 '19 at 21:29
  • @stovfl Would the while loop actually have an effect on the position of the text? – scotty3785 Nov 18 '19 at 16:26
  • @scotty3785 ***"while loop ... effect ... position"***: I don't know, if you read the given link it will block the `.mainloop()` and therefore could lead to distored layout. The OP code does not behave as described in the question. There must be another reason elsewhere. – stovfl Nov 18 '19 at 16:38

1 Answers1

0

Thank you every one.. i have figured out the problem. It was because the device sending data like"""b'123/r/n'. and this new line tag causing this problem.