代码拉取完成,页面将自动刷新
#encoding=utf-8
#usr/local/bin/python3
from flexx import app,event,ui,config
from ctypes import *
import os
import sys
print(sys.path)
confPath=r"D://conf.ini"
CERTFILE = r'C:\Users\user\OneDrive\code space\python/tmp/self-signed.crt'
KEYFILE = r'C:\Users\user\OneDrive\code space\python/tmp/self-signed.key'
config.ssl_certfile = CERTFILE
config.ssl_keyfile = KEYFILE
class setPile(app.PyComponent):
x=0
def init(self):
self.widget = Example(self)
#self.updata_partcipantes()
@event.action
def echo(self,data):
confPath=data[3]
with open(confPath,"w") as f:
f.write(
"""HBTIMEOUT=30000
DEVICECODE={deviceCode}
POWTYPE={powtype}
GUN0NUM={gun0}
GUN1NUM={gun1}""".format(deviceCode=data[0][:-2],powtype=data[0][-2:-1],gun0=data[0][-1:],gun1=data[1][-1:]))
with open(confPath)as f:
line=f.read()
#print(line,data)
os.system(u"""netsh interface ip set address name="本地连接1" source=static addr={ip} mask=255.255.255.0 gateway={gate}""".format(ip=("192.168.100."+data[2]),gate="192.168.100.1"))
windll.user32.MessageBoxA(0,(line+"\n"+'192.168.100.'+data[2]).encode('gb2312'),u' 信息'.encode('gb2312'),0)
print(line);
class Example(ui.Widget):
def init(self,pycomp):
self.pycomp = pycomp
with ui.VBox(flex=1):
self.lab1=ui.Label(text='0号枪编号:')
self.l1 = ui.LineEdit(placeholder_text='431')
self.lab1=ui.Label(text='1号枪编号:')
self.l2 = ui.LineEdit(placeholder_text="432")
self.lab1=ui.Label(text='设置主机IP:')
self.l3 = ui.LineEdit(text="2")
self.lab1=ui.Label(text='位置')
self.l4 = ui.LineEdit(text=r"D://charge_station/conf.ini")
self.b1=ui.Button(text='确定')
self.label1=ui.Label(flex=1,wrap=True,text=confPath)
@event.reaction('b1.pointer_down')
def _add_label_text(self, *events):
#print(self.l1.text)
self.send_data((self.l1.text,self.l2.text,self.l3.text,self.l4.text))
self.label1.set_text(confPath)
#self.label1.set_text("输入成功")
@event.action
def send_data(self, data):
self.pycomp.echo(data)
@event.action
def receive_data(self, data):
0
#a = app.App(setPile)
#m = a.launch("firefox-browser") # for use during development
#app.run()
app.serve(setPile,'setPile')
app.start()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。