[pygtk] Can't run PyGTK more than once from embedded Python

Romain Behar romainbehar at yahoo.com
Sun Jan 8 04:57:10 WST 2006


Hello John,
 
> > Is there something to care of when importing
> > PyGTK from an embedded Python interpreter
> > to fix this issue?
> 
> I'm not aware of anything, though it may not
> have been tried before so there might be
> problems.  Can you a file a bug in bugzilla
> with a minimal program that reproduces the
> problem?

I've made some more tests and found why the PyGTK
scripts run once, but couldn't find how to solve the
issue. My application runs Python scripts using
PyRun_SimpleString(). It works fine when running
simple scripts. However, a PyGTK script opening a
window never ends (hence the bug: a new script can't
start since the previous is still running).

Running the following script from the command line
opens a window, but after closing it, one needs to hit
Ctrl-C to stop the Python interpreter:


import pygtk
pygtk.require('2.0')
import gtk

class Base:
	def __init__(self):
		self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
		self.window.show()

	def main(self):
		gtk.main()

print __name__
if __name__ == "__main__":
	base = Base()
	base.main()


Is it possible for the above script to quit when the
window's closed?

 Cheers,

  Romain



		
__________________________________________ 
Yahoo! DSL – Something to write home about. 
Just $16.99/mo. or less. 
dsl.yahoo.com 



More information about the pygtk mailing list