CGTalk > Software > Autodesk Maya > Maya Programming
Login register
Thread Closed share thread « Previous Thread | Next Thread »
 
Thread Tools Search this Thread Display Modes
Old 01-19-2007, 01:29 AM   #1
rstebbing
New Member
Randy Stebbing
Lead Technical Artist
High Moon Studios
Vista, USA
 
Join Date: Apr 2003
Posts: 4
Send a message via AIM to rstebbing
wxPython and Maya 8.5

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.

--Randy Stebbing
__________________
Randy Stebbing
 
Old 01-19-2007, 04:56 PM   #2
mhovland
MEL Monkey
 
mhovland's Avatar
portfolio
Mike Hovland
Technical Artist
Robomodo
Chicago, USA
 
Join Date: Feb 2002
Posts: 580
I would like to know if anyone has had any success with this as well.

Any examples of working scripts would be great.
__________________
mike hovland
lead technical artist
Robomodo

Life beats down and crushes the soul... art reminds you that you have one. - Stella Adler
 
Old 01-19-2007, 06:20 PM   #3
rstebbing
New Member
Randy Stebbing
Lead Technical Artist
High Moon Studios
Vista, USA
 
Join Date: Apr 2003
Posts: 4
Send a message via AIM to rstebbing
mhovland,

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
__________________
Randy Stebbing
 
Old 01-22-2007, 02:41 PM   #4
mhovland
MEL Monkey
 
mhovland's Avatar
portfolio
Mike Hovland
Technical Artist
Robomodo
Chicago, USA
 
Join Date: Feb 2002
Posts: 580
I was asking about UI integration using wxWidgets.
__________________
mike hovland
lead technical artist
Robomodo

Life beats down and crushes the soul... art reminds you that you have one. - Stella Adler
 
Old 01-24-2007, 04:56 PM   #5
NolanSW
No Coffee=Grumpy Rigger
 
NolanSW's Avatar
portfolio
Sean
Character TeeDee
2k Games
USA
 
Join Date: Apr 2003
Posts: 498
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.

-Sean
__________________
===============
snolan.net

 
Old 01-24-2007, 05:03 PM   #6
sporadic
Software Engineer
 
sporadic's Avatar
portfolio
Geoff Wedig
Programming Lead
Magic Leap
Los Angeles, USA
 
Join Date: May 2004
Posts: 377
Keep us informed. I'm really eager to find out if this works too. It would really make gui creation for tools so much easier.
__________________

 
Old 01-24-2007, 06:22 PM   #7
arcsecond
Veteran
James Parks
Lead Rigging TD
Wild Canary
Hollyweird, USA
 
Join Date: Jan 2002
Posts: 40
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.

-James
 
Old 01-26-2007, 10:34 PM   #8
nessus
Frequenter
NeS
Vancouver, Canada
 
Join Date: Oct 2005
Posts: 195
Quote:
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.

-James


this would be indeed neat!! so wxPython works with XSI as well?
 
Old 01-26-2007, 11:39 PM   #9
arcsecond
Veteran
James Parks
Lead Rigging TD
Wild Canary
Hollyweird, USA
 
Join Date: Jan 2002
Posts: 40
http://www.xsi-blog.com/archives/138

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.

I REALLY need to find some time to experiment.

-James
 
Old 01-27-2007, 01:50 AM   #10
smaragden
Smaragden
 
smaragden's Avatar
Fredrik Brännbacka
Technical Director
Mad Crew
Stockholm, Sweden
 
Join Date: Aug 2002
Posts: 95
Gets the same result here with Maya. Tk works but it freezes Maya until you quit the Tk UI.
Will digg deeper into this.

/Smaragden
__________________
Fredrik Brännbacka | Technical Director
-------------------------------------
mail: fredrik@madcrew.se
web: http://www.madcrew.se
 
Old 01-29-2007, 04:34 AM   #11
cgcreator
Veteran
 
cgcreator's Avatar
portfolio
Keith Lackey
Technical Director
Weta Digital
Miramar, New Zealand
 
Join Date: Jun 2003
Posts: 47
Send a message via AIM to cgcreator
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.
__________________
Keith E. Lackey
Technical Director
 
Old 02-15-2007, 05:03 PM   #12
Greken
Coffee free
Andreas Ekoutsidis
Senior Engineer
Important Looking Pirates
Stockholm, Sweden
 
Join Date: Aug 2004
Posts: 63
Send a message via MSN to Greken
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)

Regards,
Pedalen

Last edited by Pedalen : 02-15-2007 at 05:30 PM.
 
Old 02-16-2007, 01:57 AM   #13
arcsecond
Veteran
James Parks
Lead Rigging TD
Wild Canary
Hollyweird, USA
 
Join Date: Jan 2002
Posts: 40
Rock on! I don't suppose you'd mind posting your solution?

Can't wait until my studio upgrades to 8.5 and I can start applying some of this stuff.

-James
 
Old 02-16-2007, 08:14 AM   #14
FiendishVegan
Frequenter
 
FiendishVegan's Avatar
XXX
USA
 
Join Date: Feb 2004
Posts: 109
Here's the Aloys Baillet's code stripped down and functioning in Maya.

To use:
1. save code to a file called WxMaya.py (or whatever you want to call it) and place in scripts directory
2. in Maya type:

import WxMaya
WxMaya.createMayaFrame()

Code:
import os import wx import traceback import win32gui, win32process class MayaSubFrame(wx.Frame): _topLvlMayaWinHandle = None @classmethod def create(cls,*args,**kw): app = wx.GetApp() if app is None: app = wx.App(redirect=False) topHandle = MayaSubFrame._getMayaTopWindow() top = wx.PreFrame() print topHandle top.AssociateHandle(topHandle) top.PostCreate(top) app.SetTopWindow(top) try: frame = cls(top,app,*args,**kw) frame.Show(True) except: print cls.__name__ print traceback.format_exc() frame = None top.DissociateHandle() return frame @staticmethod def _getMayaTopWindow(): if MayaSubFrame._topLvlMayaWinHandle is not None: return MayaSubFrame._topLvlMayaWinHandle def callback(handle,winList): winList.append(handle) return True wins = [] win32gui.EnumWindows(callback, wins) currentId = os.getpid() for handle in wins: tpid,pid = win32process.GetWindowThreadProcessId(handle) if pid == currentId: title = win32gui.GetWindowText(handle) if title.startswith("Autodesk Maya"): MayaSubFrame._topLvlMayaWinHandle = handle return handle return None def __init__(self,parent,app,id,title,pos=(150,150),si ze=(320,240),style=wx.DEFAULT_FRAME_STYLE|wx.FRAME _FLOAT_ON_PARENT|wx.FRAME_NO_TASKBAR): wx.Frame.__init__(self,parent,id,title,pos,size,st yle) self.app = app self.panel = None self.Bind(wx.EVT_CLOSE,self.OnClose) def OnClose(self,event): self.Show(False) self.Destroy() win32gui.DestroyWindow(self.GetHandle()) win32gui.SetFocus(MayaSubFrame._topLvlMayaWinHandl e) class MayaFrame(MayaSubFrame): def __init__(self,parent,app): MayaSubFrame.__init__(self,parent,app,-1,"Maya WxFrame",size=(320,240)) def createMayaFrame(): MayaFrame.create() return True



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
 
Old 02-16-2007, 08:34 AM   #15
Greken
Coffee free
Andreas Ekoutsidis
Senior Engineer
Important Looking Pirates
Stockholm, Sweden
 
Join Date: Aug 2004
Posts: 63
Send a message via MSN to Greken
Awesome, that's a lot more striped down than I was able to do. Will be using this instead of my noobish code
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright ©2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 03:34 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.