Has anyone tried importing wx or Tkinter yet under Maya 8.5 and using them to build user interfaces with Maya 8.5's python integration? If so what was your experience? Did it work? Are there any issues to be aware of? So far I've only converted some of my existing MEL scripts to Python using the Maya/Python UI calls. This works fine but I'm interested if the wxpython modules might also work.

Are you asking for specific WX Python examples working under Maya or just examples of converted Mel scripts re-written to work using the Python calls?

My initial question was asking about the possiblity of wxPython integration. And I'm still hoping that someone can report flawless integration with wxPython as this could really open up the types of userinterface toolset available for Maya.

For those wondering about the more general Python/Maya integration I can report that Autodesk has done a great job at providing Python specific documentation to each command. All the Mel documentation examples have been converted to give corresponding Python/Maya examples.
--Randy Stebbing

I'm really wondering if this could work too. Building UI's in Maya as we all now really sucks. However both Tkinker and wxPython would really step it up with having some really robust applications inside of maya.

Here is some help from Autodesk with regards to this. Haven't tried it yet. Hoping someone would give this a go and let us know if they had any success.

Quote:Issue

When I try this in the Script Editor in Python Mode:

from Tkinter import *

I get this error:

# File "C:\Program Files\Autodesk\Maya8.5\Python\lib\lib-tk\Tkinter.py", line 38, in ?
# import _tkinter # If this fails your Python may not be configured for Tk
# ImportError: No module named _tkinter

Solution

You need to find the _tkinter.so or .pyd in a separate installation of Python and put that into your PYTHONPATH for Maya to find it. _tkinter is not included with the Python distribution in Maya itself. You can look in the Python/DLLs directory to see which compiled modules are being distributed with Maya.

Note: Tkinter is not support within Maya at this current time.

If this would work, I've been dying to make a component editor that works. Having looked at some of the gridLayouts used in wxPython I was blown away by simple it is to create.

Originally Posted by arcsecond:It would be especially nice if a wxPython solution could be found. Then we could use the same GUI setup for both Maya and XSI. This would greatly help integration between the two.

apparently so. I haven't had time to experiment with it yet. Looks like you have to do a little work and write your own frame subclass. But it appears that you can make it think it's a child of the main XSI window.

I was trying to do the same thing with Tkinter but ran up against roadblocks. When you have the Tk window open it steals focus from the main XSI window and you can't do anything in the main XSI window until you close the Tk window. I suppose it might be possible to do the integration trick with a subclassed frame in Tk the same way it's being done in wx.

The reason this is happening is because the gui is stuck in a loop and never give control back to maya. One way to get around this would be to send the interface call to a thread. This would free maya back up to do what it needs to do while the interface loop is doing its thing in a thread. One of the problems i can see with doing this is that maya commands themself are not thread safe, meaning that you will have to use the "executeInMainThreadWithResult" command in order to use them. maya.utils.executeInMainThreadWithResult( command, arg1, arg2 )Seems like a huge pain though.

Hmm I don't know about Tkinter but after several hours of struggling I was able to launch wxPython inside Maya 8.5 by modifying Aloys Baillets files for XSI. No focus problem or freezing stuff what so ever. At least I haven't noticed any such behaivor yet.
The only bad news is that I wasn't able to run it inside 7 using cgkit's Python-plugin. Anyone had luck with that?

Edit: Ops! I forgot to change title name of the application it tries to find (since Maya 7 is called "Maya 7" and Maya 8.5 is called "Autodesk Maya...". So there is no bad news! It works on 7 as well (as long as you use Windows, otherwise this entire hack won't work at all)

Note: Do not copy/paste this to the script editor and try to run it there. The script looks for a process id that returns "Autodesk Maya" and running from the script editor actually returns the id of "Output Window" which will cause the script to fail.

The script is totally stripped down and is only a blank wxFrame. I appologize for the total lack of comments.

I hope that this works as well for everyone else. If you have any sort of issues with this script, please post your results here.

__________________
"The secret to creativity is knowing how to hide your sources." -- Albert Einstein

Follow Us On:

The CGSociety

The CGSociety is the most respected and accessible global organization for creative digital artists. The CGS supports artists at every level by offering a range of services to connect, inform, educate and promote digital artists worldwide. More about us on TheArtSociety.com