Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'm not sure if this is germane, but some googling turns up that PyQt is pretty popular inside of Maya. You could try the technique <a href="http://www.highend3d.com/boards/lofiversion/index.php/t236041.html" rel="nofollow noreferrer">here</a> or <a href="http://www.highend3d.com/boards/index.php?showtopic=242116" rel="nofollow noreferrer">here</a> (explained <a href="http://groups.google.com/group/xsi_list/msg/dd500eb2420f3417?" rel="nofollow noreferrer">here</a> with source code) of creating a new threadloop via Maya and executing inside of that. It seems Maya has a module included that sets up a new thread object, with a QApplication inside it:</p> <pre><code>def initializePumpThread(): global pumpedThread global app if pumpedThread == None: app = QtGui.QApplication(sys.argv) pumpedThread = threading.Thread(target = pumpQt, args = ()) pumpedThread.start() </code></pre> <p>and then sets up a function to process the Qt events:</p> <pre><code>def pumpQt(): global app def processor(): app.processEvents() while 1: time.sleep(0.01) utils.executeDeferred( processor ) </code></pre> <p>You can probably do something similar with wxPython as well. (utils.executeDeferred is a Maya function.) Be sure to check out how to create a <a href="http://wiki.wxpython.org/Non-Blocking%20Gui" rel="nofollow noreferrer">non-blocking GUI</a> on the wxPython wiki. Instead of processEvents(), you'll want to set up an event loop and check for "Pending" events inside the (hopefully renamed?) pumpQt function above. (The wxPython source has a <a href="http://cvs.wxwidgets.org/viewcvs.cgi/wxWidgets/wxPython/samples/mainloop/mainloop.py" rel="nofollow noreferrer">Python implementation</a> of MainLoop.) Likely this should be done through the app.Yield() function, but I'm not sure.</p> <pre><code>def pumpWx(): global app def processor(): app.Yield(True) while 1: time.sleep(0.01) utils.executeDeferred( processor ) def initializePumpThread(): global pumpedThread global app if pumpedThread == None: app = wx.App(False) pumpedThread = threading.Thread(target = pumpWx, args = ()) pumpedThread.start() </code></pre> <p>The wxPython docs <a href="http://www.wxpython.org/docs/api/wx-module.html#SafeYield" rel="nofollow noreferrer">indicate SafeYield()</a> is preferred. Again, this seems like it could be a first step, but I'm not sure it will work and not just crash horribly. (There's some discussion about what you want to do on the <a href="http://www.nabble.com/app.MainLoop-vs.-Pending-Dispatch-td17921845.html" rel="nofollow noreferrer">wxPython mailing list</a> but it's from a few minor versions of wx ago.) There is also some indication in various forums that this technique causes problems with keyboard input. You might also try doing:</p> <pre><code>def processor(): while app.Pending(): app.Dispatch() </code></pre> <p>to deal with the current list of events.</p> <p>Good luck!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload