filepath=askopenfilenames( initialdir=".", title="选择配置文件")
if not filepath:
return
- with open( filepath[0], "r") as fd:
- self.jsondata = json.load(fd)
- self.cfg_ui.json_update( self.jsondata)
+ try:
+ with open( filepath[0], "r") as fd:
+ self.jsondata = json.load(fd)
+ self.cfg_ui.json_update( self.jsondata)
+ except:
+ messagebox.showwarning(title='', message='加载配置文件失败')
+
def on_btn_savefile( self ):
filepath=asksaveasfilename( filetype=[ ("JsON", "*.json"), ( "All Files", "*")])
self.cfg_ui.json_update( self.cfg_data)
self.cfg_json_str = self.formate_jsdata( self.cfg_data )
except :
- messagebox.showwarning(title='访问设备异常', message='设备通信异常')
+ messagebox.showwarning(title='', message='设备通信异常')
pass
#v = dev.read_devinfo_regs()
#print( v )
dev.write_regs( 8300, [0x0000] ) #save cfg to flash #TODO debug ...
except :
- messagebox.showwarning(title='访问设备异常', message='设备通信异常')
+ messagebox.showwarning(title='', message='设备通信异常')
pass
if __name__ == '__main__':
root = Tk()