基于上一篇python TK之串口工具制作(1)的博文,我在这里做一些功能的完善,添加文本框数据编写发送功能。
首先我们在TK界面制作页面(按键初始化)增加文本框以及数据发送按钮:
#按钮初始化
def Button_Init():
global root
global com_list_tk
global Test_Log
global Entry_SN
#串口读取写入
Button(text='扫描串口', command=Scan_Com, width=24, height=3,font=('宋体', 11)).grid(row=0, column=0)
Button(text='选择串口', command=Select_Com, width=24, height=3,font=('宋体', 11)).grid(row=1, column=0)
#Button(text='选择串口', command=send_Com, width=24, height=3, font=('宋体', 11)).grid(row=0, column=1)
Button(text='删除文本框', command=Delete_Text, width=24, height=3, font=('宋体', 11)).grid(row=0, column=1)
Button(text='关闭串口', command=close_serial, width=24, height=3, font=('宋体', 11)).grid(row=1, column=1)
Button(text='发送', command=send_data, width=10, height=2, font=('宋体', 11)).grid(row=3, column=2)
Entry_SN = Entry(root)
Entry_SN.grid(row=3, column=0, ipadx=131, ipady=10,columnspan=2)
com_list_tk = Listbox(root)
com_list_tk.grid(row=2, column=0, ipadx=28, ipady=60)
Test_Log = scrolledtext.ScrolledText(root, width=23, height=20, font=('宋体', 11)

本文详细介绍了一款串口工具V1.01的制作过程,包括使用Python和Tkinter库进行界面设计,实现串口扫描、选择、发送数据等功能,并提供了完整的代码示例。
最低0.47元/天 解锁文章
3825

被折叠的 条评论
为什么被折叠?



