Search code examples
pythontkintertkinter-layout

Label placement in Tkinter Python


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"


Solution

  • 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.