Dear friends,
I'm newbie to python and pygtk, and I'm writing a simple network
application.
The application should show a window with a progress bar while the python
code using the os module to do a ping checks.

While I'm running the short program the window with simple label won't show
on the screen until the python finish all the code (after do the ping
checks).

Anyone know how could I show the window widget (and his content) in parallel
while the rest of the codeis running?

Here is my code (it also available here: http://www.shorttext.com/3u1gd)

#!/usr/bin/env python
#
#
#
import pygtk
pygtk.require('2.0')
import gtk
import os
import re


#Create simple gtk window with label
w = gtk.Window()
l = gtk.Label("pppp")
w.add(l)
w.show_all()

PINGIP=False #Set the PINGIP flag to false
ConnectionIP = False
ConnectionDNS = False

#Check Ping to IP Address and DNS function
def CheckPing(IP):
   global PINGIP
   command = 'ping -c 2 ' + IP
   w=os.popen(command) #Make ping test in the OS level
   while (True):
       s=w.readline()
       if re.search("ttl=",s):
           PINGIP = True # If the ping test results include "TTL" then
connection is alive
       if not s:
           break

CheckPing("212.143.162.141")
CheckPing("64.233.183.104")

# Connection to IP address is ok? do ping to host name
if PINGIP:
   ConnectionIP = True
   PINGIP=False
   CheckPing("www.nba.com")
   CheckPing("www.google.com")
   if PINGIP:
       ConnectionDNS = True

#Print the results
if ConnectionIP and ConnectionDNS:
   print "Connection is OK"
elif ConnectionIP:
   print "Only IP - no DNS"
else:
   print "No connection"

if __name__ == "__main__":
   gtk.main()



Thanks,
Miki
[EMAIL PROTECTED]
_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to