[Stackless] Importing PyGTK

Richard Tew richard.m.tew at gmail.com
Sat Sep 1 12:03:12 CEST 2007

On 9/1/07, s.debellefon at libertysurf.fr <s.debellefon at libertysurf.fr> wrote:
> you were right, there was a problem in my own setup. I started from a clean install and compiled all the python
> modules with the headers of stackless and it imported correctly. (Same thing with mysqldb)

Hi Sebastian,

I hope you don't mind, but I have readded the list.  I think it is
important to get this information out there for others to see in case
they have the same problem.

> In PyGTK, one can release the control using gobject.timeout_add:
> class HelloWorld:
>         def hello(self, widget, data=None):
>                 print "Hello World"
>         def schedule (self):
>                 gobject.timeout_add(50, self.schedule)
>                 stackless.schedule()
>         def __init__(self):
>                 self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
>                 self.window.connect("delete_event", self.delete_event)
>                 self.window.set_border_width(10)
>                 self.button = gtk.Button("Hello World")
>                 self.button.connect("clicked", self.hello, None)
>                 self.window.add(self.button)
>                 self.button.show()
>                 self.window.show()
>                 ### Here is the trick
>                 gobject.timeout_add(50, self.schedule)
>                 stackless.schedule()
>         def main(self):
>                 stackless.tasklet(gtk.main)()
> Thank you for your help!

No, thank you for putting in the time to get it to work :-)

Since it is the weekend and it raining here in Iceland (the former
happens periodically and the latter happens continually ;-) ) I sat
down and tested the Windows binaries.

- I installed Python 2.5 on Windows Vista.
- I downloaded and extracted the Stackless binaries over the 2.5 installation.
- I installed the PyGTK binary packages for 2.5:
  - PyGTK
  - PyGObject
  - PyCairo
  (all of these were necessary to get your code to run)
- I wrapped your code above and extended it a little.

The Windows builds of PyGTK work fine with Stackless.  And they were
not compiled against the Stackless headers.  I suspect that this is
related to the same problems which happened with PyQT - namely that
GCC is not as reliable as Microsoft Visual C.  Don't get me wrong, I
love gcc, especially using it from the command line compared to MSVC,
but it has compilation bugs as the QT/sip experience showed and as
this experience indicates to me.

I have attached my extended script.  I should probably clean it up a
little and check it into the Stackless examples repository.


More information about the Stackless mailing list