Jump to content

wxPython Crashes with multiple instances


Darkster

Recommended Posts

Hi guys,
 
When I try to run a wxpython GUI (like the one below) it crashes Houdini if I run it twice without closing the original.
 
I'm using the method described in the docs to run it in a separate thread so it doesn't lock up Houdini. I've tried using a  wx.SingleInstanceChecker(), but I'm not sure how to properly integrate it into my scripts.

 

Has anyone encountered this problem before and/or have any solutions?
 
Test code:

import wx

class testFrame(wx.Frame):
    def __init__(self, *args, **kwds):
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.button_test = wx.Button(self, wx.ID_ANY, "Click me!")
        self.SetTitle("Crashing Test Frame")
        self.SetSize((100, 100))

        self.Bind(wx.EVT_BUTTON, self.evt_test, self.button_test)
        
        sizer_test = wx.BoxSizer(wx.VERTICAL)
        sizer_test.Add(self.button_test, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL | wx.ADJUST_MINSIZE, 20)
        self.SetSizer(sizer_test)
        self.Layout()

    def evt_test(self, event):
        print "Click"


def runWxApp(app, window):

    def processWxEvents():
        while event_loop.Pending():
            event_loop.Dispatch()
            app.ProcessPendingEvents()

    def onClose(event):
        window.Show(False)
        window.Destroy()
        processWxEvents()
        hou.ui.removeEventLoopCallback(processWxEvents)
    window.Bind(wx.EVT_CLOSE, onClose)

    event_loop = wx.EventLoop()
    wx.EventLoop.SetActive(event_loop)
    hou.ui.addEventLoopCallback(processWxEvents)


app = wx.PySimpleApp()
frame = testFrame(None, wx.ID_ANY, "testFrame")
frame.Show()
runWxApp(app, frame)

 

I'm running Linux Centos 6 & Houdini 13.0.376

 

Any help would be appreciated.

Link to comment
Share on other sites

Thanks for taking a look.

 

At the moment it's not much of a issue, it's just very annoying when it happens. Normally I force the GUI window to always stay on top, so this issue is normally not a problem, but it's easy to forget you have a GUI open if it's minimized or you don't have always.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...