wxPython with GTK: Interface not being refreshed when it should + random crashes

Hi, I'm using wxPython 2.8.8.0 with Gnome 2.24.1 on Ubuntu 8.10. My
wxPython app, DamnVid - it's open source, so feel free to look at the
code: http://damnvid.googlecode.com/ - starts up fine for the most
part. But when I try to convert a video (it's a video conversion app,
after all), the progress bar is supposed to be updated every so often
to reflect the progress of the video conversion (obviously). It works
great on Windows, but on Ubuntu, here's what happens:
- If my cursor is over DamnVid's main window once the conversion
starts, everything behaves as expected (except a few times where the
program abruptly ends with a segmentation fault, but that behavior is
unpredictable, it seems (and it doesn't happen on Windows))
- If the cursor is elsewhere (but the window keeps its focus!), the
conversion starts fine and finishes fine, but the progress bar and all
changes I try to make to the window are not updated while the
conversion is ongoing. If I put my mouse over the window during the
conversion, nothing happens. If I click on a control-less space in the
window during the conversion, nothing happens. If I put my mouse over
a button, nothing happens and the button does not change appearance
like it normally should. However, if I do something like clicking a
button or resizing a column in the window's main ListCtrl, the
interface refreshes itself (shows the current progress and all), and
keeps refreshing until the end of the conversion as it should, no
matter where my cursor goes. The button I clicked on to make this
happen, though, does not execute the code it's supposed to execute,
unless I click on that button again.
I often get other problems too, though they happen unpredictably: When
using the SetStatusText method on the main window/frame, the status
text does change, but the status text that was there before is not
erased, so both labels appear at once, overlapping each other and
making the status bar unreadable. The program also crashes randomly
with errors like "python: ../../src/xcb_io.c:228: _XSend: Assertion
`!dpy->xcb->request_extra' failed.", "python: ../../src/xcb_lock.c:77:
_XGetXCBBuffer: Assertion `((int) ((xcb_req) - (dpy->request)) >= 0)'
failed.", or even this longer error message: "(python:24717):
Gdk-CRITICAL **: gdk_window_set_geometry_hints: assertion
`GDK_IS_WINDOW (window)' failed
(python:24717): Gdk-CRITICAL **: gdk_window_resize: assertion
`GDK_IS_WINDOW (window)' failed
(python:24717): Gdk-CRITICAL **:
gdk_window_freeze_toplevel_updates_libgtk_only: assertion `window !=
NULL' failed
(python:24717): Gdk-CRITICAL **:
gdk_window_thaw_toplevel_updates_libgtk_only: assertion
`private->update_and_descendants_freeze_count > 0' failed"
Once again, never had these problems under Windows, everything runs
just fine. This feels weird, I actually sound like I'm praising
Windows here!
Anything I can do to diagnose these problems? And prevent them, if possible?

WindPower wrote:

Hi, I'm using wxPython 2.8.8.0 with Gnome 2.24.1 on Ubuntu 8.10. My
wxPython app, DamnVid - it's open source, so feel free to look at the
code: http://damnvid.googlecode.com/ - starts up fine for the most
part. But when I try to convert a video (it's a video conversion app,
after all), the progress bar is supposed to be updated every so often
to reflect the progress of the video conversion (obviously). It works
great on Windows, but on Ubuntu, here's what happens:
- If my cursor is over DamnVid's main window once the conversion
starts, everything behaves as expected (except a few times where the
program abruptly ends with a segmentation fault, but that behavior is
unpredictable, it seems (and it doesn't happen on Windows))
- If the cursor is elsewhere (but the window keeps its focus!), the
conversion starts fine and finishes fine, but the progress bar and all
changes I try to make to the window are not updated while the
conversion is ongoing. If I put my mouse over the window during the
conversion, nothing happens. If I click on a control-less space in the
window during the conversion, nothing happens. If I put my mouse over
a button, nothing happens and the button does not change appearance
like it normally should. However, if I do something like clicking a
button or resizing a column in the window's main ListCtrl, the
interface refreshes itself (shows the current progress and all), and
keeps refreshing until the end of the conversion as it should, no
matter where my cursor goes. The button I clicked on to make this
happen, though, does not execute the code it's supposed to execute,
unless I click on that button again.

This sounds like a classic case of blocking the event loop with a long running task. See

http://wiki.wxpython.org/LongRunningTasks
http://wiki.wxpython.org/Non-Blocking_Gui

If that doesn't help then see http://wiki.wxpython.org/MakingSampleApps and give us a small runnable app script that we can use to easily see what you are doing wrong.

···

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

I got it all to work, mostly thanks to the "Communicating with events"
part. It doesn't explain why the code did work with Windows, but
thanks all the same!
I did notice an erroneous behavior while debugging the whole thing,
though. Here's a sample app:

···

--------
import wx

class MyFrame(wx.Frame):

    def __init__(self,parent,title):

        wx.Frame.__init__(self,parent,-1,title)
        panel=wx.Panel(self,-1)
        sizer=wx.BoxSizer(wx.HORIZONTAL)

        tree=wx.TreeCtrl(panel,-1,style=wx.TR_LINES_AT_ROOT|wx.TR_HAS_BUTTONS|wx.TR_FULL_ROW_HIGHLIGHT)

        sizer.Add(tree,1,wx.EXPAND)

        root=tree.AddRoot('Root item')
        tree.AppendItem(root,'Sub-item')

        panel.SetSizer(sizer)

        self.Bind(wx.EVT_TREE_SEL_CHANGED,self.onTreeSelectionChanged,tree)

        tree.SelectItem(root,True)
    def onTreeSelectionChanged(self,event):
        print 'o hai'

class MyApp(wx.App):

    def OnInit(self):

        frame=MyFrame(None,'Test')

        frame.Show(True)

        return True

app=MyApp(0)

app.MainLoop()
--------
As you can see, it's a simple dialog with a TreeCtrl. Within the
__init__ function, the tree's EVT_TREE_SEL_CHANGED event is bound, and
then the root item is selected.
On Windows, the onTreeSelectionChanged is triggered at that point
(twice, according to someone else I got to test this program!). On
Ubuntu, it is not. I don't know which is the correct behavior, but I
thought I'd report this anyway.
Cheers!

On Sat, Feb 28, 2009 at 4:26 PM, Robin Dunn <robin@alldunn.com> wrote:

WindPower wrote:

Hi, I'm using wxPython 2.8.8.0 with Gnome 2.24.1 on Ubuntu 8.10. My
wxPython app, DamnVid - it's open source, so feel free to look at the
code: http://damnvid.googlecode.com/ - starts up fine for the most
part. But when I try to convert a video (it's a video conversion app,
after all), the progress bar is supposed to be updated every so often
to reflect the progress of the video conversion (obviously). It works
great on Windows, but on Ubuntu, here's what happens:
- If my cursor is over DamnVid's main window once the conversion
starts, everything behaves as expected (except a few times where the
program abruptly ends with a segmentation fault, but that behavior is
unpredictable, it seems (and it doesn't happen on Windows))
- If the cursor is elsewhere (but the window keeps its focus!), the
conversion starts fine and finishes fine, but the progress bar and all
changes I try to make to the window are not updated while the
conversion is ongoing. If I put my mouse over the window during the
conversion, nothing happens. If I click on a control-less space in the
window during the conversion, nothing happens. If I put my mouse over
a button, nothing happens and the button does not change appearance
like it normally should. However, if I do something like clicking a
button or resizing a column in the window's main ListCtrl, the
interface refreshes itself (shows the current progress and all), and
keeps refreshing until the end of the conversion as it should, no
matter where my cursor goes. The button I clicked on to make this
happen, though, does not execute the code it's supposed to execute,
unless I click on that button again.

This sounds like a classic case of blocking the event loop with a long running task. See

LongRunningTasks - wxPyWiki
Non-Blocking Gui - wxPyWiki

If that doesn't help then see http://wiki.wxpython.org/MakingSampleApps and give us a small runnable app script that we can use to easily see what you are doing wrong.

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

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

WindPower wrote:

I got it all to work, mostly thanks to the "Communicating with events"
part. It doesn't explain why the code did work with Windows, but
thanks all the same!
I did notice an erroneous behavior while debugging the whole thing,
though. Here's a sample app:

As you can see, it's a simple dialog with a TreeCtrl. Within the
__init__ function, the tree's EVT_TREE_SEL_CHANGED event is bound, and
then the root item is selected.
On Windows, the onTreeSelectionChanged is triggered at that point
(twice, according to someone else I got to test this program!). On
Ubuntu, it is not. I don't know which is the correct behavior, but I

The answer is, 'it depends' :-/

The general rule is that calling a set value type of method or set selection type of method should not cause command events to be emitted. The exception to the rule is that if a particular method was already breaking the rule when the rule was created then it should continue to do so. I'm not sure which side of the fence this method falls on, but it should probably be made consistent, so please enter a bug ticket about it.

···

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