Mayapy gui

Anybody have any luck getting Tkinter or other basic UI to allow input when running mayapy.exe?

(… searching …)

Found answer:

Tkinter for Maya install instructions

So anybody else loving mayapy.exe? This thing rocks for batch processing.

Hey Count,
I’ve messed with Tkinter and wxPython in Maya, neither seems to have any threading support and therefor any guis created seem to make Maya unstable. I’m no pro at how to set up proper threading so that’s probably one of the major issues. It does look like Autodesk has spent some time with PyQt though. That’s the next thing I’m going to look in, in the devkit/other folder there are a lot of resources to look at.

I’m using Wing IDE which I’ve managed to hook into maya and maya.standalone…it rocks!

Hope that helps,
Shawn

The threading is a big obstacle in any UI creation in Maya it seems.

I managed to get dotNET UIs under Maya up and running nicely with threading support, however, I haven’t managed to make it run “embedded” in Maya yet. I don’t even know whether it’s possible or not, but it’d be a very nice (in fact the last piece of puzzle) feature for more complex UIs requiring user interaction etc…

I’ll be looking into Qt and PyQt for Maya in the near future as that seems to be the best way to do UIs in Maya even though it requires you to install the Qt framework. I’ll have to take a look at the licence of Qt as it seems a bit limiting in terms of “open source” stuff.

Anyways, I’d recommend looking into Qt as well as .NET as well as standard Maya GUI (for some simple UIs).

I’m know little about mayapy, but wxPython does support multiple threads (at least outside of Maya).

If you have the Docs and Demos package installed (separate download from wxPython), and run the Demo browser app, in the “Processes and Events” section there’s a couple good threading examples: DelayedResult and Threads.

I’m not too concerned about the threading issue right now as I need some UI for mayapy (command line) right now.

I’m spending more and more sessions in mayapy because it batch processes so much faster. But sometimes I need to input a little info so a basic UI is needed. Tkinter seems to suffice for now.

Unfortunately we’re on Maya8.5 so I can’t use PyQt:
http://groups.google.com/group/python_inside_maya/web/using-pyqt-with-maya

Hey, I’ve only dabbled with it, but easygui might do what you need for simple dialogs and user input. It’s basically a wrapper for tkinter

http://easygui.sourceforge.net/

useful?

neil

Python .NET if you fancy WinForms and/or WPF.

[QUOTE=djTomServo;1820]Python .NET if you fancy WinForms and/or WPF.[/QUOTE]

Yeah, there are some undoubtful pros to .NET and PythonNET in general:

  1. Very easy to deploy
  2. Wide area of usage
  3. Wide userbase (pretty much every Vista machine as well as most of the XP machines run it)
  4. Some portability on Linux via Mono (is it called mono?)
  5. OpenSource baby!
  6. It’s Python, man!

as well as some cons:

  1. Maya wasn’t built around .NET so gettint it working together requires more than you’d like to (like in Max, where .NET is natively supported)
  2. You essenitally write much more code than with Qt or even the default MEL objects
  3. PythonNET is pretty much a R&D project, in my opinion, so prepare for some trouble as well as no support for the latest .NET versions.
  4. Embedding forms in Maya’s thread is a pain and quite franky I still haven’t figured it out yet, so this is a bit of a problem if you want to create some nice, complex UI tools for the artists to work with (Skinning Utils for example etc…)

So yeah, here goes. I’m yet to investigate Qt a bit more since it runs natively on all platforms as well as Autodesk itself suggests using it (a Maya GUI rewrite soon?).

[QUOTE=loocas;1823]Yeah, there are some undoubtful pros to .NET and PythonNET in general:

  1. Maya wasn’t built around .NET so gettint it working together requires more than you’d like to (like in Max, where .NET is natively supported)
    [/quote]
    not really, if you know a bit about gui programming and thread management, getting forms and wpf to play nice under maya isn’t that tricky
  1. You essenitally write much more code than with Qt or even the default MEL objects

again, not really. typing maya.utils.executeInMainThreadWithResult isn’t THAT bad:D:

  1. PythonNET is pretty much a R&D project, in my opinion, so prepare for some trouble as well as no support for the latest .NET versions.

True to a point, but since even .NET 3.5 uses clr 2.0, Python .NET is just fine with it.

  1. Embedding forms in Maya’s thread is a pain and quite franky I still haven’t figured it out yet, so this is a bit of a problem if you want to create some nice, complex UI tools for the artists to work with (Skinning Utils for example etc…)

again, it’s all about thread protecting your handlers. We’ve been using Python .NET in production here for the better part of a few months and haven’t had any hitches with it at all, even with the GUI stuff. . .if you have some stuff you’re trying to get running and can pass it around, i’d be more than happy to take a look and see what’s going on.

Yeah the only really downside to Python .NET in Maya is that it does require a little more engineering savvy, so there’s a bit of a learning curve, but like i said, we’ve had nothing but good results from it and will probably continue using it for a while.

Hey Seth,

It would be awsome if you had an exmaple of how to get a ‘hello world’ type of window working, as a threaded app inside of Maya. I’ve read the docs and havn’t gotten anything to work myself. Any info would be greatly appreciated.
Cheers,
Shawn

[QUOTE=shawner;1843]Hey Seth,

It would be awsome if you had an exmaple of how to get a ‘hello world’ type of window working, as a threaded app inside of Maya. I’ve read the docs and havn’t gotten anything to work myself. Any info would be greatly appreciated.
Cheers,
Shawn[/QUOTE]

Happy to oblige, i’ve actually been meaning to put together a little doc on (at least how i think you should be) getting up and running with Maya and Python .NET. There are a few different ways to do it, but i think the way we’re doing it here is one of the more flexible and probably the simplest codewise (that doesn’t mean there’s less code, it just means it isn’t as complex:wink:). Give me the weekend and i’ll post some stuff to the t-a wiki.

Oh, man, please! I’d (and I think I wouldn’t be the only one) be really interested in some of your examples!

Could you, please, post a simple “Hello World” (as already requested) form with a button (creating a sphere for example) embedded in Maya, properly threaded, so that the user can use the form similarly to the Outliner (floating on top in Maya, always available, nothing lagging). I’d very much appretiate that!

So far, I got .NET forms threaded and usable inside Maya, but I can’t get them “embedded”, I bumped into HWNDs, PIDs etc… but I couldn’t find a way to connect it all together.

I’d love to use .NET in Maya as I’m used to it from 3ds Max and as I said, .NET is available on most machines I develop tools for, so, this’d be the 1st choice, followed by Qt, but since we don’t run Linux nor Mac, I’d prefer to stick with .NET.

Thanks a lot in advance!

[QUOTE=djTomServo;1828]not really, if you know a bit about gui programming and thread management, getting forms and wpf to play nice under maya isn’t that tricky

again, not really. typing maya.utils.executeInMainThreadWithResult isn’t THAT bad:D:

True to a point, but since even .NET 3.5 uses clr 2.0, Python .NET is just fine with it.

again, it’s all about thread protecting your handlers. We’ve been using Python .NET in production here for the better part of a few months and haven’t had any hitches with it at all, even with the GUI stuff. . .if you have some stuff you’re trying to get running and can pass it around, i’d be more than happy to take a look and see what’s going on.

Yeah the only really downside to Python .NET in Maya is that it does require a little more engineering savvy, so there’s a bit of a learning curve, but like i said, we’ve had nothing but good results from it and will probably continue using it for a while.[/QUOTE]

[QUOTE=djTomServo;1844]Give me the weekend and i’ll post some stuff to the t-a wiki.[/QUOTE]

You’re the man!

Quick Update on this since it seems to be in demand (hopefully no one has any critical work dependent on getting this up and running, like oh say, we did!:D:): Did most of the writing this weekend, going to take a few days and put some actual samples (c# project, assembly binaries, python script, etc) and try and post the whole shebang this week. This isn’t exactly how we’re doing it at bungie (our microsoft overlords are pretty not cool with us sharing that sort of thing, go fig) but should be enough to get you started.

As a hint for any of the more intrepid among you, we do most of our stuff at bungie through WCF. . .(i did not say this, i was not here:blank:)

[QUOTE=djTomServo;1868]Quick Update on this since it seems to be in demand (hopefully no one has any critical work dependent on getting this up and running, like oh say, we did!:D:): Did most of the writing this weekend, going to take a few days and put some actual samples (c# project, assembly binaries, python script, etc) and try and post the whole shebang this week. This isn’t exactly how we’re doing it at bungie (our microsoft overlords are pretty not cool with us sharing that sort of thing, go fig) but should be enough to get you started.

As a hint for any of the more intrepid among you, we do most of our stuff at bungie through WCF. . .(i did not say this, i was not here:blank:)[/QUOTE]

That smiley face is gold! :D::D::D::D:

As for your time and efforts, I’m totally looking forward to your solutions! I’d love to get our .NET pipe up and running, however, those little glitches in tools dev make it kinda hard for me to push it through.

Thanks again, man! Much appretiated!

Hey Seth,

Anything you can offer would be most excellent, I’m personally on Maya in Linux and I’m looking at PyQt, I’m sure the workflow is similar no matter what the platform. Personally it’s not project critical for me. It’s really awsome that you’re taking the time to put some stuff together as this is something way beyond me at the moment. Thank you sooo much.

Cheers,
Shawn

We’ve been using PyQT at work with great success, maya provides a pumpThread module which allows for maya to do the threading itself, seems pretty well integrated overall.

It’s great to finally be able to have a tree graph in a tool in maya. Plus the Designer tool kicks major ass since UI design was my least favorite part about mel.

I think there’s some docs under /devkit in your maya instalation folder and you can download pyQT4 since it’s open source. Worth giving a shot.

On a side note we are also using Python.NET and the clr module for some other stuff, like communication from maya to other tools but not for UI that’s more hardcore than I want to get with UI programming. I did have to change some stuff in the source code to get the assemblies to load correctly, not sure if it was a 64bit issue or just an issue with the dlls comming from the visual studio SDK.

I’d recommend checking those 2 out, wxPython and PythonCard didnt seem to want to play well with maya

I have PyQt installed on linux which was a bit of a pain to get working, but it’s nice that it’s in. I can get the examples working fine. Does anyone use pumpThread a lot? I can use it fine with user made UIs. What I want to do is use QtGui.QFileDialog with pumpthread, but can’t seem to get it working. Any idea?

Cheers,
Shawn

I have this working, I just call the function from one of the buttons, this calls the fileDialog in directory mode, and the message is what you want to appear in the browser like “Select directory”, the myWindow variable is your tool’s main window (so the browser gets centered properly)

Let me know if that works for you

def launchBrowser(msg):
global myWindow
fileName = QtGui.QFileDialog.getExistingDirectory(myWindow,msg)
return fileName

On a related subject, i finally got around to posting this:

Python .NET In Maya Tutorial

Apologies for my timeliness, it’s that time of year again:rolleyes: If anyone wants the Visual C# project and the python script that goes along with the project, PM me and i’ll send them both along. I’m not sure if this is what people were asking for exactly, but this is how we do most of the simple stuff here and it works pretty well. The one thing i know people were asking about, docking, we don’t do, but we’re working on a plugin to do that sort of thing. It’s a little trickier than it should be since MPxUIControl isn’t as open as one would like, but hopefully we’ll figure something out:p: