bobh at hendry.net
Sun Jun 27 16:34:46 MDT 2010
Works on Linux Redhat platform.
Try debugging it
On Mon, 28 Jun 2010, Brian Rowlands (Greymouth High School) wrote:
> Hi Folks
> New to both Wing IDE and Python and busily trying to get my head around
> threads when I tried a simple example off the WWW.
> It falls over in Wing IDE but the author assures me it works fine when
> he tested it after I wrote to him. He had someone else test it and it
> worked too on a windows platform ( which is what I'm using).
> Wind IDE Personal doesn't report any errors.
> Am I allowed to ask if someone could test it via their IDE and let me
> know the results please?
> If so, code is shown below.
> #!/usr/bin/env python
> #-*- coding:utf-8 -*-
> # By Chris Oliver <chris at excid3.com>
> # Adapted from
> import pygtk
> import gobject
> import gtk
> import threading
> class HelloWorld:
> def __init__(self):
> Initializes the GTK application, in our case, create the
> and other widgets
> # Create a window
> self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
> # Setup the application to exit GTK when the window is closed
> self.window.connect("destroy", self.destroy)
> # Create a button
> self.button = gtk.Button("Hello World")
> # Make the button call self.hello() when it is clicked
> self.button.connect("clicked", self.hello_helper)
> # Add the button into the window
> # Display the button and the window
> def hello(self, widget, data=None):
> import time
> print "Hello"
> def hello_helper(self, widget, data=None):
> print "starting new thread"
> threading.Thread(target=self.hello, args=(widget, data)).start()
> def main(self):
> This function starts GTK drawing the GUI and responding to
> like button clicks
> def destroy(self, widget, data=None):
> This function exits the application when the window is
> Without this the GTK main thread would continue running
> while no
> interface would be displayed. We want the application to
> exit when
> the window is closed, so we tell the GTK loop to stop so we
> if __name__ == "__main__":
> # Create an instance of our GTK application
> app = HelloWorld()
More information about the wingide-users