Guillaum
Guillaum

Reputation:

How to debug PYGTK program

When python raise an exception in the middle of a pygtk signal handling callback, the exception is catched by the gtk main loop, its value printed and the main loop just continue, ignoring it.

If you want to debug, with something like pdb (python -m pdb myscript.py), you want that when the exception occure PDB jump on it and you can start debuging. Because of that it's not possible.

How can i debug pygtk program then ?

Upvotes: 8

Views: 2303

Answers (1)

nosklo
nosklo

Reputation: 222862

You can't make pdb jump to the exception, since the exception is caught and silenced by gtk's main loop.

One of the alternatives is using pdb.set_trace():

import pdb
pdb.set_trace()

See pdb documentation.

Alternatively you can just use Winpdb:

It is a platform independent graphical GPL Python debugger with support for remote debugging over a network, multiple threads, namespace modification, embedded debugging, encrypted communication and is up to 20 times faster than pdb.

Features:

  • GPL license. Winpdb is Free Software.
  • Compatible with CPython 2.3 through 2.6 and Python 3000
  • Compatible with wxPython 2.6 through 2.8
  • Platform independent, and tested on Ubuntu Gutsy and Windows XP.
  • User Interfaces: rpdb2 is console based, while winpdb requires wxPython 2.6 or later.

Screenshot
(source: winpdb.org)

Upvotes: 5

Related Questions