代码拉取完成,页面将自动刷新
#coding=utf-8
#import libs
import sys
import time
import serial_tools_cmd
import serial_tools_sty
import Fun
import tkinter
import tkinter.ttk
import tkinter.font
#Add your Varial Here: (Keep This Line of comments)
#Define UI Class
THREAD_FLag = True
class serial_tools:
def __init__(self,root,isTKroot = True):
uiName = self.__class__.__name__
Fun.Register(uiName,'UIClass',self)
self.root = root
Fun.Register(uiName,'root',root)
style = serial_tools_sty.SetupStyle()
if isTKroot == True:
root.title("串口通信小工具")
root.resizable(False, False)
Fun.CenterDlg(uiName,root,640,480)
root.iconbitmap(Fun.resource_path('com.ico')) # 更改窗口图标
root['background'] = '#efefef'
Form_1= tkinter.Canvas(root,width = 10,height = 4)
Form_1.place(x = 0,y = 0,width = 640,height = 480)
Form_1.configure(bg = "#efefef")
Form_1.configure(highlightthickness = 0)
Fun.Register(uiName,'Form_1',Form_1)
Group_1_Variable = Fun.AddTKVariable(uiName,'Group_1')
Group_1_Variable.set(1)
#Create the elements of root
Text_2 = tkinter.Text(Form_1)
Fun.Register(uiName,'Text_2',Text_2)
Text_2.place(x = 0,y = 0,width = 627,height = 328)
Text_2.configure(relief = "sunken")
Text_2_Scrollbar = tkinter.Scrollbar(Text_2,orient=tkinter.VERTICAL)
Text_2_Scrollbar.place(x = 607,y = 0,width = 20,height = 328)
Text_2_Scrollbar.config(command = Text_2.yview)
Text_2.config(yscrollcommand = Text_2_Scrollbar.set)
Fun.Register(uiName,'Text_2_Scrollbar',Text_2_Scrollbar)
LabelFrame_3 = tkinter.LabelFrame(Form_1,text="串口设置",takefocus = True,width = 10,height = 4)
Fun.Register(uiName,'LabelFrame_3',LabelFrame_3)
LabelFrame_3.place(x = 12,y = 348,width = 240,height = 120)
LabelFrame_3.configure(relief = "groove")
Label_4 = tkinter.Label(LabelFrame_3,text="串口",width = 10,height = 4)
Fun.Register(uiName,'Label_4',Label_4)
Label_4.place(x = 8,y = 9,width = 53,height = 20)
Label_4.configure(relief = "flat")
Label_5 = tkinter.Label(LabelFrame_3,text="波特率",width = 10,height = 4)
Fun.Register(uiName,'Label_5',Label_5)
Label_5.place(x = 1,y = 38,width = 68,height = 21)
Label_5.configure(relief = "flat")
ComboBox_6_Variable = Fun.AddTKVariable(uiName,'ComboBox_6')
ComboBox_6 = tkinter.ttk.Combobox(LabelFrame_3,textvariable=ComboBox_6_Variable, state="readonly")
Fun.Register(uiName,'ComboBox_6',ComboBox_6)
ComboBox_6.place(x = 84,y = 9,width = 100,height = 20)
ComboBox_6.configure(state = "readonly")
ComboBox_7_Variable = Fun.AddTKVariable(uiName,'ComboBox_7')
ComboBox_7 = tkinter.ttk.Combobox(LabelFrame_3,textvariable=ComboBox_7_Variable, state="readonly")
Fun.Register(uiName,'ComboBox_7',ComboBox_7)
ComboBox_7.place(x = 85,y = 41,width = 100,height = 20)
ComboBox_7.configure(state = "readonly")
ComboBox_7["values"]=['9600','19200','38400','57600','115200']
ComboBox_7.current(0)
RadioButton_8 = tkinter.Radiobutton(LabelFrame_3,variable=Group_1_Variable,value=1,text="ASCII",anchor=tkinter.W)
Fun.Register(uiName,'RadioButton_8',RadioButton_8,'ASCII','Group_1')
RadioButton_8.place(x = 4,y = 72,width = 100,height = 20)
RadioButton_9 = tkinter.Radiobutton(LabelFrame_3,variable=Group_1_Variable,value=0,text="Hex",anchor=tkinter.W)
Fun.Register(uiName,'RadioButton_9',RadioButton_9,None,'Group_1')
RadioButton_9.place(x = 114,y = 72,width = 100,height = 20)
LabelFrame_10 = tkinter.LabelFrame(Form_1,text="操作",takefocus = True,width = 10,height = 4)
Fun.Register(uiName,'LabelFrame_10',LabelFrame_10)
LabelFrame_10.place(x = 262,y = 352,width = 365,height = 120)#lock
LabelFrame_10.configure(relief = "groove")
Button_12 = tkinter.Button(LabelFrame_10,text="打开串口",width = 10,height = 4)
Fun.Register(uiName,'Button_12',Button_12)
Button_12.place(x = 36,y = 65,width = 100,height = 28)#lock
Button_12.configure(command=lambda:serial_tools_cmd.Button_12_onCommand(uiName,"Button_12"))
Button_13 = tkinter.Button(LabelFrame_10,text="发送数据",width = 10,height = 4)
Fun.Register(uiName,'Button_13',Button_13)
Button_13.place(x = 189,y = 66,width = 100,height = 28)#lock
Button_13.configure(command=lambda:serial_tools_cmd.Button_13_onCommand(uiName,"Button_13"))
Text_11 = tkinter.Text(Form_1)
Fun.Register(uiName,'Text_11',Text_11)
Text_11.place(x = 273,y = 368,width = 340,height = 50)#lock
Text_11.configure(relief = "sunken")
Text_11_Scrollbar = tkinter.Scrollbar(Text_11,orient=tkinter.VERTICAL)
Text_11_Scrollbar.place(x = 320,y = 0,width = 20,height = 50)
Text_11_Scrollbar.config(command = Text_11.yview)
Text_11.config(yscrollcommand = Text_11_Scrollbar.set)
Fun.Register(uiName,'Text_11_Scrollbar',Text_11_Scrollbar)
#Inital all element's Data
Fun.InitElementData(uiName)
#Add Some Logic Code Here: (Keep This Line of comments)
serial_tools_cmd.rootinit()
def exit(self):
# 程序退出时控制线程关闭,不然会有残留的进程存在
serial_tools_cmd.THREAD_FLag = False
time.sleep(0.2)
root.destroy()
#Create the root of Kinter
if __name__ == '__main__':
root = tkinter.Tk()
MyDlg = serial_tools(root)
root.protocol('WM_DELETE_WINDOW', MyDlg.exit)
root.mainloop()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。