简体   繁体   English

Label 放置在 Tkinter Python

[英]Label placement in Tkinter Python

Hy, I am trying to make a GUI with tkinter.嗨,我正在尝试用 tkinter 制作一个 GUI。 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.一开始它在中心显示 0.00...但是当我单击开始时它显示实时数据。 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)

点击开始后

在点击“开始”之前

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.这是因为设备发送的数据如"""b'123/r/n'. 和这个新的行标签导致了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM