how to debug UI freezes

I have made some change to my code and now the UI freezes (not
immediately but after about a second). I expect the cause to be a
python object that is cleared while it shouldn't. It would help me a
great deal if I can get some debugging out of wxPython on which object
it hangs.

Is there a way to get this output?

Paul

···

--
Paul Sijben tel: +31334566488
Eemvalley Systems & Technology fax: +31334557523
the Netherlands http://eemvalley.com

Add debug printouts.

    import traceback

    def print_info():
        info = traceback.extract_stack(limit=2)[-2][:2]
        print "File: %s Lineno: %i"%info

Toss the above somewhere and call print_info() around where you think
there may be problems, and it will tell you where and what has been
executed.

- Josiah

···

Paul Sijben <sijben@eemvalley.com> wrote:

I have made some change to my code and now the UI freezes (not
immediately but after about a second). I expect the cause to be a
python object that is cleared while it shouldn't. It would help me a
great deal if I can get some debugging out of wxPython on which object
it hangs.

Is there a way to get this output?

Josiah,

   That's extremely useful information. I sprinkle my code with print
statements, but I'm printing variables to figure out what's broken. I like
this approach for its added information.

Thank you from me, too,

Rich

···

On Tue, 9 Jan 2007, Josiah Carlson wrote:

Add debug printouts.

--
Richard B. Shepard, Ph.D. | The Environmental Permitting
Applied Ecosystem Services, Inc. | Accelerator(TM)
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863

The easiest thing to do is to get a proper python IDE with debugger. Then you can simply step through all the code. Or just hit run, pause the program when it hangs and let the debugger tell you the current stack trace.

···

Am 09.01.2007, 19:45 Uhr, schrieb Rich Shepard <rshepard@appl-ecosys.com>:

On Tue, 9 Jan 2007, Josiah Carlson wrote:

Add debug printouts.

Josiah,

   That's extremely useful information. I sprinkle my code with print
statements, but I'm printing variables to figure out what's broken. I like
this approach for its added information.

Thank you from me, too,

Rich

I use winpbd when I need it. It's a useful extension to pdb. Otherwise, I
much prefer emacs for writing code.

Rich

···

On Tue, 9 Jan 2007, Nitro wrote:

The easiest thing to do is to get a proper python IDE with debugger. Then
you can simply step through all the code. Or just hit run, pause the
program when it hangs and let the debugger tell you the current stack
trace.

--
Richard B. Shepard, Ph.D. | The Environmental Permitting
Applied Ecosystem Services, Inc. | Accelerator(TM)
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863

My problem is not that python hangs, it is that wxPython hangs. My python code runs along nicely. So a python IDE does not help me I believe.

Nitro wrote:

···

Am 09.01.2007, 19:45 Uhr, schrieb Rich Shepard <rshepard@appl-ecosys.com>:

On Tue, 9 Jan 2007, Josiah Carlson wrote:

Add debug printouts.

Josiah,

   That's extremely useful information. I sprinkle my code with print
statements, but I'm printing variables to figure out what's broken. I like
this approach for its added information.

Thank you from me, too,

Rich

The easiest thing to do is to get a proper python IDE with debugger. Then you can simply step through all the code. Or just hit run, pause the program when it hangs and let the debugger tell you the current stack trace.

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

OK I have been able to figure out when it goes wrong, the UI becomes
frozen when I try to resize the UI (or switch tabs in a notebook around
the panel I have been working on).

When I run this bit of UI as a stand alone script (see also my earlier
postings) The UI is displayed but I have the size problem I posted about.
So I guess there is nothing intrinsically wrong with the code, but
clearly I have messed up somewhere.

Which process can I use to find out what I have done wrong?

Paul

Paul Sijben wrote:

···

My problem is not that python hangs, it is that wxPython hangs. My
python code runs along nicely. So a python IDE does not help me I
believe.

Nitro wrote:

Am 09.01.2007, 19:45 Uhr, schrieb Rich Shepard >> <rshepard@appl-ecosys.com>:

On Tue, 9 Jan 2007, Josiah Carlson wrote:

Add debug printouts.

Josiah,

   That's extremely useful information. I sprinkle my code with print
statements, but I'm printing variables to figure out what's broken.
I like
this approach for its added information.

Thank you from me, too,

Rich

The easiest thing to do is to get a proper python IDE with debugger.
Then you can simply step through all the code. Or just hit run, pause
the program when it hangs and let the debugger tell you the current
stack trace.

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

--
Paul Sijben tel: +31334566488
Eemvalley Systems & Technology fax: +31334557523
the Netherlands http://eemvalley.com

Hi Paul,

Paul Sijben wrote:

My problem is not that python hangs, it is that wxPython hangs. My python code runs along nicely. So a python IDE does not help me I believe.

wxPython is written in Python :wink: , I use the debugger from Boa in these situations.

But I liked also Josiah's suggestion.

Werner

Are you try Winpdb?

···

El mar, 09-01-2007 a las 17:17 +0100, Paul Sijben escribió:

I have made some change to my code and now the UI freezes (not
immediately but after about a second). I expect the cause to be a
python object that is cleared while it shouldn't. It would help me a
great deal if I can get some debugging out of wxPython on which object
it hangs.

Is there a way to get this output?

Paul

--
Mario Lacunza <mlacunza@gmail.com>

Werner F. Bruhin wrote:

Hi Paul,

Paul Sijben wrote:

My problem is not that python hangs, it is that wxPython hangs. My
python code runs along nicely. So a python IDE does not help me I
believe.

wxPython is written in Python :wink: , I use the debugger from Boa in
these situations.

My application is very much multithreaded. I use Wing as and IDE but had
to forgo the debugging from it as it could not handle multi-threaded
debugging.

But I liked also Josiah's suggestion.

that one actually game me more info when I did it wrong. called the
print_info function while I hadn't saved yet the file in which I had
defined it. So I got an error. But when this happened the panel I
thought I had just created was not drawn yet!

So I'll investigate that next. Looks like I am doing something wrong or
is it just my understanding that is wrong and should the drawing lag
behind the function calls that ought to create it?

···

Werner

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

--
Paul Sijben tel: +31334566488
Eemvalley Systems & Technology fax: +31334557523
the Netherlands http://eemvalley.com

Whoa bitten by it again. I created the objects but not in the right
thread. So wxPython did not see them and barfed.

Solution, move the code to the master class of the panel I wanted to
put something in, and now it works.

Tomorrow I’ll address the issue of getting the events from this
sub-panel back to the thread that is interested in them…

Paul Sijben wrote:

···

wxPython-users-unsubscribe@lists.wxwidgets.orgwxPython-users-help@lists.wxwidgets.org

-- Paul Sijben tel: +31334566488
Eemvalley Systems & Technology fax: +31334557523
the Netherlands

http://eemvalley.com

One thing to remember when mixing threads and GUI is that the only
thread that should be doing anything GUI related is the GUI thread.
Everything else should pass events to the GUI in order to manipulate it
(explicitly via wx.PostEvent, or implicitly via wx.CallAfter)

- Josiah

···

Paul Sijben <sijben@eemvalley.com> wrote:

OK I have been able to figure out when it goes wrong, the UI becomes
frozen when I try to resize the UI (or switch tabs in a notebook around
the panel I have been working on).

When I run this bit of UI as a stand alone script (see also my earlier
postings) The UI is displayed but I have the size problem I posted about.
So I guess there is nothing intrinsically wrong with the code, but
clearly I have messed up somewhere.

Which process can I use to find out what I have done wrong?

Paul Sijben wrote:

So I'll investigate that next. Looks like I am doing something wrong or
is it just my understanding that is wrong and should the drawing lag
behind the function calls that ought to create it?

It can, depending on a number of factors such as the platform, what state the program is in at the moment, whether the changes have been flushed to the display yet or if it is buffering them, etc.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Paul Sijben wrote:

OK I have been able to figure out when it goes wrong, the UI becomes
frozen when I try to resize the UI (or switch tabs in a notebook around
the panel I have been working on).

When I run this bit of UI as a stand alone script (see also my earlier
postings) The UI is displayed but I have the size problem I posted about.
So I guess there is nothing intrinsically wrong with the code, but
clearly I have messed up somewhere.

Which process can I use to find out what I have done wrong?

I usually find that educated guesses and trial-and-error can get me a long ways towards finding a solution. Also selectively cutting out parts of the program to isolate the offending bit will help, especially if you can do it in such a way that it devolves from complex to simple.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!