@@ -29,9 +29,9 @@ def PrintException():
2929 filename = f .f_code .co_filename
3030 print ('Exception in {}, line {}; {}' .format (filename , lineno , exc_obj ))
3131
32- def check_ip (s : str ):
32+ def check_ip (s : str , req = True ):
3333 if s == "" :
34- return False
34+ return not req
3535 spl = s .split ("." )
3636 if len (spl ) != 4 :
3737 sg .Popup ("Wrong IP format.\n Value should be similar to 255.255.255.255" )
@@ -505,6 +505,11 @@ def run(self) -> None:
505505 self .closeDevice ()
506506 self .resetGui ()
507507 self .getDevices ()
508+ elif event == "dynamicBut" :
509+ # Clear out IPv4 settings to default to
510+ self .window .Element ('ip' ).update ('' )
511+ self .window .Element ('mask' ).update ('' )
512+ self .window .Element ('gateway' ).update ('' )
508513 self .window .close ()
509514
510515 @property
@@ -528,13 +533,34 @@ def getConfigs(self):
528533
529534 try :
530535 if self .isPoE ():
531- self .window .Element ('ip' ).update (conf .getIPv4 ())
532- self .window .Element ('mask' ).update (conf .getIPv4Mask ())
533- self .window .Element ('gateway' ).update (conf .getIPv4Gateway ())
534- self .window .Element ('dns' ).update (conf .getDnsIPv4 ())
535- self .window .Element ('dnsAlt' ).update (conf .getDnsAltIPv4 ())
536+ if conf .getIPv4 () == '0.0.0.0' :
537+ self .window .Element ('ip' ).update ('' )
538+ else :
539+ self .window .Element ('ip' ).update (conf .getIPv4 ())
540+
541+ if conf .getIPv4Mask () == '0.0.0.0' :
542+ self .window .Element ('mask' ).update ('' )
543+ else :
544+ self .window .Element ('mask' ).update (conf .getIPv4Mask ())
545+
546+ if conf .getIPv4Gateway () == '0.0.0.0' :
547+ self .window .Element ('gateway' ).update ('' )
548+ else :
549+ self .window .Element ('gateway' ).update (conf .getIPv4Gateway ())
550+
551+ if conf .getDnsIPv4 () == '0.0.0.0' :
552+ self .window .Element ('dns' ).update ('' )
553+ else :
554+ self .window .Element ('dns' ).update (conf .getDnsIPv4 ())
555+ if conf .getDnsAltIPv4 () == '0.0.0.0' :
556+ self .window .Element ('dnsAlt' ).update ('' )
557+ else :
558+ self .window .Element ('dnsAlt' ).update (conf .getDnsAltIPv4 ())
536559 self .window .Element ('networkTimeout' ).update (int (conf .getNetworkTimeout ().total_seconds () * 1000 ))
537- self .window .Element ('mac' ).update (conf .getMacAddress ())
560+ if conf .getMacAddress () == '00:00:00:00:00:00' :
561+ self .window .Element ('mac' ).update ('' )
562+ else :
563+ self .window .Element ('mac' ).update (conf .getMacAddress ())
538564 for el in CONF_INPUT_USB :
539565 self .window [el ].update ("" )
540566 else :
@@ -646,10 +672,10 @@ def flashConfig(self):
646672 if check_ip (values ['ip' ]) and check_ip (values ['mask' ]) and check_ip (values ['gateway' ]):
647673 conf .setStaticIPv4 (values ['ip' ], values ['mask' ], values ['gateway' ])
648674 else :
649- if check_ip (values ['ip' ]) and check_ip (values ['mask' ]) and check_ip (values ['gateway' ]):
675+ if check_ip (values ['ip' ], req = False ) and check_ip (values ['mask' ], req = False ) and check_ip (values ['gateway' ], req = False ):
650676 conf .setDynamicIPv4 (values ['ip' ], values ['mask' ], values ['gateway' ])
651- if values [ 'dns' ] != "" and values [ 'dnsAlt' ] != "" :
652- conf .setDnsIPv4 (values ['dns' ], values ['dnsAlt' ])
677+
678+ conf .setDnsIPv4 (values ['dns' ], values ['dnsAlt' ])
653679 if values ['networkTimeout' ] != "" :
654680 if int (values ['networkTimeout' ]) >= 0 :
655681 conf .setNetworkTimeout (timedelta (seconds = int (values ['networkTimeout' ]) / 1000 ))
@@ -658,6 +684,8 @@ def flashConfig(self):
658684 if values ['mac' ] != "" :
659685 if check_mac (values ['mac' ]):
660686 conf .setMacAddress (values ['mac' ])
687+ else :
688+ conf .setMacAddress ('00:00:00:00:00:00' )
661689 else :
662690 if values ['usbTimeout' ] != "" :
663691 if int (values ['usbTimeout' ]) >= 0 :
0 commit comments