完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
本帖最后由 lee_st 于 2018-1-23 15:13 编辑
昨晚折腾到凌晨2点,确定了使用wxpython,今天又时间,就开始了界面设计,先来张图看看 是使用wxpython设计的界面,当然是按照个人的需要做的,方便自己项目的测试,如果各位不喜欢这界面,我也没有办法哦。 给大家提供一下源代码哦 # -*- coding: utf-8 -*- import wx import wx.xrc class serial ( wx.Frame ): def __init__( self, parent ): wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = u"串口助手", pos = wx.DefaultPosition, size = wx.Size( 559,568 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL ) self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize ) sergrid = wx.GridBagSizer( 0, 0 ) sergrid.SetFlexibleDirection( wx.BOTH ) sergrid.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED ) self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, u"串口选择:", wx.Point( 1,1 ), wx.DefaultSize, 0 ) self.m_staticText1.Wrap( -1 ) sergrid.Add( self.m_staticText1, wx.GBPosition( 0, 0 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 ) self.m_rcvtext = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size( 300,200 ), wx.TE_AUTO_URL|wx.TE_LEFT|wx.TE_MULTILINE ) sergrid.Add( self.m_rcvtext, wx.GBPosition( 0, 2 ), wx.GBSpan( 8, 2 ), wx.ALL, 6 ) self.m_send2but = wx.Button( self, wx.ID_ANY, u"发送2", wx.DefaultPosition, wx.DefaultSize, 0 ) sergrid.Add( self.m_send2but, wx.GBPosition( 9, 0 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 ) self.m_clr2but = wx.Button( self, wx.ID_ANY, u"清空2", wx.DefaultPosition, wx.DefaultSize, 0 ) sergrid.Add( self.m_clr2but, wx.GBPosition( 9, 1 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 ) self.m_send3but = wx.Button( self, wx.ID_ANY, u"发送3", wx.DefaultPosition, wx.DefaultSize, 0 ) sergrid.Add( self.m_send3but, wx.GBPosition( 10, 0 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 ) self.m_clr3but = wx.Button( self, wx.ID_ANY, u"清空3", wx.DefaultPosition, wx.DefaultSize, 0 ) sergrid.Add( self.m_clr3but, wx.GBPosition( 10, 1 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 ) self.m_send3but = wx.Button( self, wx.ID_ANY, u"发送4", wx.DefaultPosition, wx.DefaultSize, 0 ) sergrid.Add( self.m_send3but, wx.GBPosition( 11, 0 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 ) self.m_clr4but = wx.Button( self, wx.ID_ANY, u"清空4", wx.DefaultPosition, wx.DefaultSize, 0 ) sergrid.Add( self.m_clr4but, wx.GBPosition( 11, 1 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 ) self.m_send5but = wx.Button( self, wx.ID_ANY, u"发送5", wx.DefaultPosition, wx.DefaultSize, 0 ) sergrid.Add( self.m_send5but, wx.GBPosition( 12, 0 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 ) self.m_clr5but = wx.Button( self, wx.ID_ANY, u"清空5", wx.DefaultPosition, wx.DefaultSize, 0 ) sergrid.Add( self.m_clr5but, wx.GBPosition( 12, 1 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 ) self.m_send6but = wx.Button( self, wx.ID_ANY, u"发送6", wx.DefaultPosition, wx.DefaultSize, 0 ) sergrid.Add( self.m_send6but, wx.GBPosition( 13, 0 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 ) self.m_clr6but = wx.Button( self, wx.ID_ANY, u"清空6", wx.DefaultPosition, wx.DefaultSize, 0 ) sergrid.Add( self.m_clr6but, wx.GBPosition( 13, 1 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 ) m_comsetChoices = [ u"COM1", u"COM2", u"COM3", u"COM4", u"COM5", u"COM6", u"COM7", u"COM8", u"COM9", u"COM10" ] self.m_comset = wx.ComboBox( self, wx.ID_ANY, u"COM1", wx.DefaultPosition, wx.DefaultSize, m_comsetChoices, 0 ) self.m_comset.SetSelection( 0 ) sergrid.Add( self.m_comset, wx.GBPosition( 0, 1 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 ) self.m_openser = wx.Button( self, wx.ID_ANY, u"打开串口", wx.DefaultPosition, wx.DefaultSize, 0 ) sergrid.Add( self.m_openser, wx.GBPosition( 5, 0 ), wx.GBSpan( 1, 1 ), wx.ALL, 8 ) self.m_clrRcvText = wx.Button( self, wx.ID_ANY, u"清空接收", wx.DefaultPosition, wx.DefaultSize, 0 ) sergrid.Add( self.m_clrRcvText, wx.GBPosition( 6, 0 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 ) self.m_checkBox1 = wx.CheckBox( self, wx.ID_ANY, u"16进制", wx.DefaultPosition, wx.DefaultSize, 0 ) sergrid.Add( self.m_checkBox1, wx.GBPosition( 6, 1 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 ) self.m_send1but = wx.Button( self, wx.ID_ANY, u"发送1", wx.DefaultPosition, wx.DefaultSize, 0 ) sergrid.Add( self.m_send1but, wx.GBPosition( 8, 0 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 ) self.m_clr1but = wx.Button( self, wx.ID_ANY, u"清空1", wx.DefaultPosition, wx.DefaultSize, 0 ) sergrid.Add( self.m_clr1but, wx.GBPosition( 8, 1 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 ) self.m_textCtrl5 = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size( 200,-1 ), wx.HSCROLL|wx.TE_AUTO_URL ) sergrid.Add( self.m_textCtrl5, wx.GBPosition( 8, 2 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 ) self.m_checkBox2 = wx.CheckBox( self, wx.ID_ANY, u"16进制", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_checkBox2.SetValue(True) sergrid.Add( self.m_checkBox2, wx.GBPosition( 8, 3 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 ) self.m_checkBox3 = wx.CheckBox( self, wx.ID_ANY, u"16进制", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_checkBox3.SetValue(True) sergrid.Add( self.m_checkBox3, wx.GBPosition( 9, 3 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 ) self.m_checkBox4 = wx.CheckBox( self, wx.ID_ANY, u"16进制", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_checkBox4.SetValue(True) sergrid.Add( self.m_checkBox4, wx.GBPosition( 10, 3 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 ) self.m_checkBox5 = wx.CheckBox( self, wx.ID_ANY, u"16进制", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_checkBox5.SetValue(True) sergrid.Add( self.m_checkBox5, wx.GBPosition( 11, 3 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 ) self.m_checkBox6 = wx.CheckBox( self, wx.ID_ANY, u"16进制", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_checkBox6.SetValue(True) sergrid.Add( self.m_checkBox6, wx.GBPosition( 12, 3 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 ) self.m_checkBox7 = wx.CheckBox( self, wx.ID_ANY, u"16进制", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_checkBox7.SetValue(True) sergrid.Add( self.m_checkBox7, wx.GBPosition( 13, 3 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 ) self.m_textCtrl6 = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size( 200,-1 ), 0 ) sergrid.Add( self.m_textCtrl6, wx.GBPosition( 9, 2 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 ) self.m_textCtrl7 = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size( 200,-1 ), 0 ) sergrid.Add( self.m_textCtrl7, wx.GBPosition( 10, 2 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 ) self.m_textCtrl8 = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size( 200,-1 ), 0 ) sergrid.Add( self.m_textCtrl8, wx.GBPosition( 11, 2 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 ) self.m_textCtrl9 = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size( 200,-1 ), 0 ) sergrid.Add( self.m_textCtrl9, wx.GBPosition( 12, 2 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 ) self.m_textCtrl10 = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size( 200,-1 ), 0 ) sergrid.Add( self.m_textCtrl10, wx.GBPosition( 13, 2 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 ) self.m_closeser = wx.Button( self, wx.ID_ANY, u"关闭串口", wx.DefaultPosition, wx.DefaultSize, 0 ) sergrid.Add( self.m_closeser, wx.GBPosition( 5, 1 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 ) self.m_staticText6 = wx.StaticText( self, wx.ID_ANY, u"校验位:", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText6.Wrap( -1 ) sergrid.Add( self.m_staticText6, wx.GBPosition( 3, 0 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 ) self.m_staticText7 = wx.StaticText( self, wx.ID_ANY, u"停止位:", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText7.Wrap( -1 ) sergrid.Add( self.m_staticText7, wx.GBPosition( 4, 0 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 ) m_comboBox4Choices = [ u"None", u"Odd", u"Even", u"Mark", u"Space" ] self.m_comboBox4 = wx.ComboBox( self, wx.ID_ANY, u"None", wx.DefaultPosition, wx.DefaultSize, m_comboBox4Choices, 0 ) sergrid.Add( self.m_comboBox4, wx.GBPosition( 3, 1 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 ) m_comboBox5Choices = [ u"1", u"1.5", u"2" ] self.m_comboBox5 = wx.ComboBox( self, wx.ID_ANY, u"1", wx.DefaultPosition, wx.DefaultSize, m_comboBox5Choices, 0 ) sergrid.Add( self.m_comboBox5, wx.GBPosition( 4, 1 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 ) self.m_staticText5 = wx.StaticText( self, wx.ID_ANY, u"数据位:", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText5.Wrap( -1 ) sergrid.Add( self.m_staticText5, wx.GBPosition( 2, 0 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 ) m_comboBox2Choices = [ u"9600", u"19200", u"38400", u"57600", u"115200", u"230400", u"460800", u"921600", wx.EmptyString, wx.EmptyString ] self.m_comboBox2 = wx.ComboBox( self, wx.ID_ANY, u"9600", wx.DefaultPosition, wx.DefaultSize, m_comboBox2Choices, 0 ) sergrid.Add( self.m_comboBox2, wx.GBPosition( 1, 1 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 ) m_comboBox3Choices = [ u"8", u"7", u"6", u"5" ] self.m_comboBox3 = wx.ComboBox( self, wx.ID_ANY, u"8", wx.DefaultPosition, wx.DefaultSize, m_comboBox3Choices, 0 ) sergrid.Add( self.m_comboBox3, wx.GBPosition( 2, 1 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 ) self.m_staticText4 = wx.StaticText( self, wx.ID_ANY, u"波特率:", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText4.Wrap( -1 ) sergrid.Add( self.m_staticText4, wx.GBPosition( 1, 0 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 ) self.SetSizer( sergrid ) self.Layout() self.Centre( wx.BOTH ) 喜欢的给点个赞,不喜欢的看看热闹即可啊,给点点评也是能接受的。 发稿与2018年1月16日下午 |
|
相关推荐 |
|
只有小组成员才能发言,加入小组>>
39个成员聚集在这个小组
加入小组3399 浏览 0 评论
6022 浏览 0 评论
2314 浏览 0 评论
5324 浏览 0 评论
1956 浏览 0 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-30 03:59 , Processed in 0.634708 second(s), Total 62, Slave 44 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号