Jun-15-2019, 07:53 PM
thanks Yoriz and Deadeye for your examples. Yoriz I guess your using windows because to get it to work on linux I changed:
DeadEye I got an attribute error:
result = os.popen("ping "+self.entry.get()+" -n 2") for line in result: self.insert_text(line)to:
result = os.popen("ping "+self.entry.get()+" -c 2") for line in result: self.insert_text(line)no output other wise
DeadEye I got an attribute error:
Output:File "/home/pi/tk_ping.py", line 53, in __init__
self.ip.trace_add("write", self.validate)
AttributeError: 'StringVar' object has no attribute 'trace_add'
and changed this line in your __init__:self.ip.trace_variable("w", self.validate)then I got a type error:
Output:File "/home/pi/tk_ping.py", line 102, in ping_thread
stdout = check_output(['ping', '-c', '3', self.ip.get()], encoding="utf8")
File "/usr/lib/python3.5/subprocess.py", line 316, in check_output
**kwargs).stdout
File "/usr/lib/python3.5/subprocess.py", line 383, in run
with Popen(*popenargs, **kwargs) as process:
TypeError: __init__() got an unexpected keyword argument 'encoding'
so I deleted the keyword encoding and everything worked:stdout = check_output(['ping', '-c', '3', self.ip.get()],)fyi, Joe