Python Forum
[Tkinter] How to get the result of a ping to show in tkinter?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] How to get the result of a ping to show in tkinter?
#5
thanks Yoriz and Deadeye for your examples. Yoriz I guess your using windows because to get it to work on linux I changed:
        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
Reply


Messages In This Thread
RE: How to get the result of a ping to show in tkinter? - by joe_momma - Jun-15-2019, 07:53 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  how to add two numbers and pass the result to the next page in tkinter? pymn 7 4,341 Feb-15-2022, 04:40 AM
Last Post: pymn
  Show the result of every count George87 10 2,672 Dec-28-2021, 10:03 PM
Last Post: deanhystad
  [Tkinter] Result not change using Tkinter cmala 2 2,757 May-17-2019, 08:12 AM
Last Post: cmala
  [Tkinter] How to show and hide tkinter entry box when select yes from drop down Prince_Bhatia 1 10,497 Jun-12-2018, 08:05 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020