add pyexe support
This commit is contained in:
@@ -23,6 +23,7 @@ python3 scomm.py
|
|||||||
* python3.x
|
* python3.x
|
||||||
* tkinter
|
* tkinter
|
||||||
* pyserial
|
* pyserial
|
||||||
|
* pyyaml
|
||||||
|
|
||||||
|
|
||||||
## 解析脚本
|
## 解析脚本
|
||||||
|
|||||||
6
app.ui
6
app.ui
@@ -275,12 +275,6 @@
|
|||||||
"text":"data-09",
|
"text":"data-09",
|
||||||
"column": 2,
|
"column": 2,
|
||||||
"row": 29
|
"row": 29
|
||||||
},
|
|
||||||
{
|
|
||||||
"name":"btn-data10",
|
|
||||||
"text":"data-10",
|
|
||||||
"column": 2,
|
|
||||||
"row": 30
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
42
pack.ui
42
pack.ui
@@ -1,42 +0,0 @@
|
|||||||
{
|
|
||||||
"Label":[
|
|
||||||
{
|
|
||||||
"name":"label-ptitle",
|
|
||||||
"text":"数据标题",
|
|
||||||
"column": 1,
|
|
||||||
"row": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name":"label-pempty",
|
|
||||||
"text":" ",
|
|
||||||
"column": 8,
|
|
||||||
"colweight": 1,
|
|
||||||
"row": 1
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"Entry": {
|
|
||||||
"name":"entry-pfile",
|
|
||||||
"bg":"gold",
|
|
||||||
"width":10,
|
|
||||||
"column": 2,
|
|
||||||
"row": 1
|
|
||||||
},
|
|
||||||
"Text":{
|
|
||||||
"name":"text-psetting",
|
|
||||||
"bg":"#cccccc",
|
|
||||||
"width":50,
|
|
||||||
"height":5,
|
|
||||||
"column": 1,
|
|
||||||
"columnspan": 10,
|
|
||||||
"rowweight": 1,
|
|
||||||
"row": 2
|
|
||||||
},
|
|
||||||
"Button":[
|
|
||||||
{
|
|
||||||
"name":"btn-psave",
|
|
||||||
"text":"保存",
|
|
||||||
"column": 10,
|
|
||||||
"row": 3
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
17
scomm.py
17
scomm.py
@@ -9,6 +9,9 @@ import tkgen.gengui
|
|||||||
import tkinter.scrolledtext
|
import tkinter.scrolledtext
|
||||||
import tkinter.filedialog
|
import tkinter.filedialog
|
||||||
|
|
||||||
|
import _locale
|
||||||
|
_locale._getdefaultlocate = (lambda *args: ['zh_CN', 'utf8'])
|
||||||
|
|
||||||
import time, datetime
|
import time, datetime
|
||||||
def tsnow():
|
def tsnow():
|
||||||
return int(time.time()*1000)
|
return int(time.time()*1000)
|
||||||
@@ -105,7 +108,7 @@ class UIproc():
|
|||||||
self.entry_baud.configure(state='disabled')
|
self.entry_baud.configure(state='disabled')
|
||||||
self.combobox_port.configure(state='disabled')
|
self.combobox_port.configure(state='disabled')
|
||||||
self.btn_onoff.configure(text='关闭串口')
|
self.btn_onoff.configure(text='关闭串口')
|
||||||
self.canvas_led.create_oval(4,4,19,19,fill='green')
|
self.canvas_led.create_oval(4,4,19,19,fill='lightgreen')
|
||||||
def serial_close(self):
|
def serial_close(self):
|
||||||
self.entry_baud.configure(state='normal')
|
self.entry_baud.configure(state='normal')
|
||||||
self.combobox_port.configure(state='normal')
|
self.combobox_port.configure(state='normal')
|
||||||
@@ -140,7 +143,7 @@ class UIproc():
|
|||||||
return False
|
return False
|
||||||
def log(self, s):
|
def log(self, s):
|
||||||
print('[sys.log]: %s'%s)
|
print('[sys.log]: %s'%s)
|
||||||
self.label_status.var.set(str(s))
|
self.label_status.var.set(len(str(s))>64 and (str(s)[:64]+' ...') or str(s))
|
||||||
def event_init(self):
|
def event_init(self):
|
||||||
self.combobox_port.bind("<<ComboboxSelected>>", lambda x:self.log(self.combobox_port.get()))
|
self.combobox_port.bind("<<ComboboxSelected>>", lambda x:self.log(self.combobox_port.get()))
|
||||||
|
|
||||||
@@ -178,7 +181,7 @@ class SerComm():
|
|||||||
if self.com.is_open:
|
if self.com.is_open:
|
||||||
data = self.com.read(self.com.in_waiting)
|
data = self.com.read(self.com.in_waiting)
|
||||||
if data:
|
if data:
|
||||||
self.ui.log('%s: recv %s bytes: %s...' % (self.com.port,len(data),str(data)[:16]))
|
self.ui.log('%s: recv %s bytes: %s' % (self.com.port,len(data),str(data)))
|
||||||
self.ui.dmesg('recv', data)
|
self.ui.dmesg('recv', data)
|
||||||
time.sleep(0.01)
|
time.sleep(0.01)
|
||||||
else:
|
else:
|
||||||
@@ -194,7 +197,7 @@ class SerComm():
|
|||||||
if data and len(data) > 0:
|
if data and len(data) > 0:
|
||||||
self.com.write(data)
|
self.com.write(data)
|
||||||
self.sendCount += len(data)
|
self.sendCount += len(data)
|
||||||
self.ui.log('%s: send %s bytes: %s...' % (self.com.port,len(data),str(data)[:16]))
|
self.ui.log('%s: send %s bytes: %s' % (self.com.port,len(data),str(data)))
|
||||||
self.ui.dmesg('send', data)
|
self.ui.dmesg('send', data)
|
||||||
else:
|
else:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
@@ -209,7 +212,7 @@ class SerComm():
|
|||||||
if data and len(data) > 0:
|
if data and len(data) > 0:
|
||||||
self.com.write(data)
|
self.com.write(data)
|
||||||
self.sendCount += len(data)
|
self.sendCount += len(data)
|
||||||
self.ui.log('%s: send %s bytes: %s...' % (self.com.port,len(data),str(data)[:16]))
|
self.ui.log('%s: send %s bytes: %s' % (self.com.port,len(data),str(data)))
|
||||||
self.ui.dmesg('send', data)
|
self.ui.dmesg('send', data)
|
||||||
|
|
||||||
def openCloseSerialProcess(self):
|
def openCloseSerialProcess(self):
|
||||||
@@ -246,9 +249,9 @@ class SerComm():
|
|||||||
self.com.close()
|
self.com.close()
|
||||||
self.ui.serial_close()
|
self.ui.serial_close()
|
||||||
self.comProgressStop = True
|
self.comProgressStop = True
|
||||||
self.ui.log('%s: open failed: %s' % (self.com.port,str(e)))
|
self.ui.log('%s: open failed' % (self.com.port))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.ui.log('%s: openClose trace: %s' % (self.com.port,str(e)))
|
self.ui.log('%s: openClose trace' % (self.com.port))
|
||||||
|
|
||||||
def clearWin(self):
|
def clearWin(self):
|
||||||
self.ui.clear_recvtext()
|
self.ui.clear_recvtext()
|
||||||
|
|||||||
15
setup.py
Normal file
15
setup.py
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
from distutils.core import setup
|
||||||
|
import py2exe
|
||||||
|
|
||||||
|
excludes = ['_gtkagg', '_tkagg', 'bsddb', 'curses', 'email', 'pywin.debugger', 'pywin.debugger.dbgcon', 'pywin.dialogs']
|
||||||
|
|
||||||
|
setup(
|
||||||
|
options = {"py2exe":
|
||||||
|
{
|
||||||
|
"excludes": excludes,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
windows = [{ 'script':'scomm.py', 'icon_resources':[(1, 'logo.ico')]}],
|
||||||
|
zipfile = None,
|
||||||
|
data_files = [('', ['usercfg.ini','app.ui','unpack.ui','data.ui','logo.ico'])]
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user