Hi I've found a good solution in a site that solved all my debug and testing 
problems...
the trick is to not invoke gtk.main(), but use this function:

def refresh_gui(delay=0):
    while gtk.events_pending():
        gtk.main_iteration_do(block=False)
    time.sleep(delay)

Every time you have to catch an event, invoke this function, for example:

somebutton.emit("clicked")
refresh_gui()
justanotherbutton.emit("clicked")
refresh_gui()

It also gives you a perfect synchronous control of the application ( testing 
and debugging within the main may cause unexpected problems).

I hope it's useful for you :)


On Fri, 29 May 2009 15:39:12 +0200
Guillaume Bouchard <guillaume.bouch...@insa-lyon.fr> wrote:

> On Fri, May 29, 2009 at 02:43:06PM +0200, Alessandro Dentella wrote:
> > > My aim is to be able to directly "jump" to the exception with "python -m
> > > pdb myprogram.py" and then '(c)ontinue' and wait for the exception to be
> > > catch by pdb.
> > 
> > I'm not really following you, but I debug gtk program using 'ipython
> > -gthread'. When you hit an exception you are jumped into a pdb interpreter
> >  run from ipython (i.e. you have completion available that you dont have in
> >  a normal pdb session). Try:
> > 
> >   ipython -gthread -pdb -- your_script.py
> 
> This really solve my problem, but :
> 
> 1) It forces me to learn ipython (ok, I'm a geek, I'll do it)
> 2) I need to have ipython installed on my computer, it's not that easy.
> 
> Thank for you help, I'm still waiting for a *pure* python/pdb solution,
> but I'm quite happy now.
> 
> PS: I put the list and you as receivers because perhaps my thanks does
> not interests others, but the quotation of your answer is quite
> interesting ;)
> 
> -- 
> Guillaume
> _______________________________________________
> pygtk mailing list   pygtk@daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://faq.pygtk.org/


-- 
Gabriele Lanaro <gabriele.lan...@gmail.com>
_______________________________________________
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to