[Tutor] I'm clearly not getting an important pygtk concept

John pythontutoraccount at gmail.com
Fri May 25 18:07:38 CEST 2007

I created the following script to test my understanding of creating 
simple pygtk GUIs.


import gtk, urllib

def pinger_shotgun():
  """This function stores an object that pings Peter's writerscafe.org 
  open_page = urllib.urlopen(web)

def plink(widget, web):
  print "I just pinged", web

web = "http://www.mywebsite.com/"
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.connect("destroy", gtk.main_quit)
ping_button = gtk.Button("ping me")
ping_button.connect("clicked", plink, web)

I am not sure what's wrong with the script as I've typed it above.  I 
expected this script to generate a button with the label "ping me". I 
expected that when I press this button that my webserver log would show 
that someone with the user-agent python-urllb just tried to access my site.

This is not happening unfortunately.  Sometimes pressing the button 
registers in my logs and sometimes it does not.  Pressing  the button 
twice in rapid succession may cause a hit to register if a single click 
did not.  Pressing the button 5 or 6 times will cause 4 or 5 hits.  What 
is it I am not understanding?


More information about the Tutor mailing list