[Maya-Python] Calling a compiled QT file in Maya

2010-08-05 Thread meljunky
Trying to get QT Ui file to work in Maya I could use the loadUI
command for example:

import maya.cmds as cmds
dialog = cmds.loadUI(f=r'C:/Python26/Lib/site-packages/PyQt4/examples/
designer/calculatorform/calculatorform.ui')
cmds.showWindow(dialog)

Don't expect the calculator to actually work but the UI opens in Maya.
But, I want to be able to edit UI elements so I used uic.compileUi to
convert the file into a Python file in hopes to make method calls to
add and remove UI elements while the window is open.

The first four lines are:
from PyQt4 import QtCore, QtGui

class Ui_CalculatorForm(object):
def setupUi(self, CalculatorForm):
...

At this point I don't know how to call the Ui_CalculatorForm class
method setupUi since it needs a different class called CalculatorForm.

Thanks in advance.

-- 
http://groups.google.com/group/python_inside_maya


Re: [Maya-Python] Calling a compiled QT file in Maya

2010-08-05 Thread David Moulder
I use multiple inheritance...

import ui_Browser
class Browser(QtGui.QWidget, ui_Browser.Ui_Form):
def __init__(self, parent=None):
super(Browser, self).__init__(parent)
self.setupUi(self)
self.setObjectName('Browser')
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)

-Dave

On Thu, Aug 5, 2010 at 2:39 PM, meljunky br...@meljunky.com wrote:

 Trying to get QT Ui file to work in Maya I could use the loadUI
 command for example:

 import maya.cmds as cmds
 dialog = cmds.loadUI(f=r'C:/Python26/Lib/site-packages/PyQt4/examples/
 designer/calculatorform/calculatorform.ui')
 cmds.showWindow(dialog)

 Don't expect the calculator to actually work but the UI opens in Maya.
 But, I want to be able to edit UI elements so I used uic.compileUi to
 convert the file into a Python file in hopes to make method calls to
 add and remove UI elements while the window is open.

 The first four lines are:
 from PyQt4 import QtCore, QtGui

 class Ui_CalculatorForm(object):
def setupUi(self, CalculatorForm):
...

 At this point I don't know how to call the Ui_CalculatorForm class
 method setupUi since it needs a different class called CalculatorForm.

 Thanks in advance.

 --
 http://groups.google.com/group/python_inside_maya




-- 
David Moulder
http://www.google.com/profiles/squish3d

-- 
http://groups.google.com/group/python_inside_maya

RE: [Maya-Python] Calling a compiled QT file in Maya

2010-08-05 Thread brian
I edited the class below to reference the class for my browser using the following lines of code to show the window:

a = Browser() 

a.show()

Two things happen.. first the window does not stay "parented" to the main Maya window and will disappear under Maya. 

Second... using the compiled version of calculatorform that comes with Qt works fine. However, when I used uic.compileUi to complile the calculatorform.ui. I get the following error:

# Error: ... global name '_' is not defined #

The compiler added a '_' that doesn't belong. For example:

CalculatorForm.setWindowTitle(_( u"Calculator Form")) 

If I removed the '_', it will open.

Also, on a ui that I created I had to comment out the following lines because:
test.setCentralWidget(self.centralwidget) 
test.setMenuBar(self.menubar) 
test.setStatusBar(self.statusbar) 

They cause a Attribute Error such as:
# Error: AttributeError ... 'Browser' object has no attribute 'setCentralWidget' #

Is there a way to get a compiled version of a Ui to open without having to edit the file?

Thanks,
-brian


 Original Message Subject: Re: [Maya-Python] Calling a compiled QT file in MayaFrom: David Moulder da...@thirstydevil.co.ukDate: Thu, August 05, 2010 8:09 amTo: python_inside_maya@googlegroups.comI use multiple inheritance...import ui_Browserclass Browser(QtGui.QWidget, ui_Browser.Ui_Form): def __init__(self, parent=None): super(Browser, self).__init__(parent) self.setupUi(self) self.setObjectName('Browser') self.setAttribute(QtCore.Qt.WA_DeleteOnClose)-Dave
On Thu, Aug 5, 2010 at 2:39 PM, meljunky br...@meljunky.com wrote:
Trying to get QT Ui file to work in Maya I could use the loadUIcommand for example:import maya.cmds as cmdsdialog = cmds.loadUI(f=r'C:/Python26/Lib/site-packages/PyQt4/examples/designer/calculatorform/calculatorform.ui')cmds.showWindow(dialog)Don't expect the calculator to actually work but the UI opens in Maya.But, I want to be able to edit UI elements so I used uic.compileUi toconvert the file into a Python file in hopes to make method calls toadd and remove UI elements while the window is open.The first four lines are:from PyQt4 import QtCore, QtGuiclass Ui_CalculatorForm(object): def setupUi(self, CalculatorForm):   ...At this point I don't know how to call the Ui_CalculatorForm classmethod setupUi since it needs a different class called CalculatorForm.Thanks in advance.--http://groups.google.com/group/python_inside_maya-- David Moulderhttp://www.google.com/profiles/squish3d
-- http://groups.google.com/group/python_inside_maya 



-- 
http://groups.google.com/group/python_inside_maya


RE: [Maya-Python] Calling a compiled QT file in Maya

2010-08-05 Thread brian
Figured outthe "_" thing, guess I should grab working code online.Appears uic.compileUI does use pyuic4

No, it doesnt run everytime an instance is made. Well, plan on makingcompile Ui files when a py is not found.

Now, the window (partically displayed) is literaly embeded in the top left corner of Maya making it unuseable. 

Thanks,
-brian


 Original Message Subject: Re: [Maya-Python] Calling a compiled QT file in MayaFrom: David Moulder da...@thirstydevil.co.ukDate: Thu, August 05, 2010 10:55 amTo: python_inside_maya@googlegroups.comTo parent your window you well need to get the Maya main window and pass that in as the parent widget 2011def GetMayaMainWindow(): ''' :returns: The QtWidget that pertains to the Maya Main Window ''' import maya.OpenMayaUI as mui import sip ptr = mui.MQtUtil.mainWindow() if ptr: return sip.wrapinstance(long(ptr), QtCore.QObject)Then pass the resulting QWidget into your classega = Browser(GetMayaMainWindow())I don't know about uic.compileUI as I pre compile all my ui files with the pyuic4.exe from the command line.Well, not exactly. I wrote a PyQt ui to browser and convert them on double click using os.systemcmd = 'pyuic4 %s  %s' % (DesignFile, OutPutFile)os.system(cmd)To be honest, it was on of the 1st things I did so I've never looked at another way to convert files. Does your method convert each and every time you make an instance?-Dave
On Thu, Aug 5, 2010 at 5:18 PM, br...@meljunky.com wrote:


I edited the class below to reference the class for my browser using the following lines of code to show the window:

a = Browser() 

a.show()

Two things happen.. first the window does not stay "parented" to the main Maya window and will disappear under Maya. 

Second... using the compiled version of calculatorform that comes with Qt works fine. However, when I used uic.compileUi to complile the calculatorform.ui. I get the following error:

# Error: ... global name '_' is not defined #

The compiler added a '_' that doesn't belong. For example:

CalculatorForm.setWindowTitle(_( u"Calculator Form")) 

If I removed the '_', it will open.

Also, on a ui that I created I had to comment out the following lines because:
test.setCentralWidget(self.centralwidget) 
test.setMenuBar(self.menubar) 
test.setStatusBar(self.statusbar) 

They cause a Attribute Error such as:
# Error: AttributeError ... 'Browser' object has no attribute 'setCentralWidget' #

Is there a way to get a compiled version of a Ui to open without having to edit the file?

Thanks,
-brian





 Original Message Subject: Re: [Maya-Python] Calling a compiled QT file in MayaFrom: David Moulder da...@thirstydevil.co.ukDate: Thu, August 05, 2010 8:09 amTo: python_inside_maya@googlegroups.comI use multiple inheritance...import ui_Browserclass Browser(QtGui.QWidget, ui_Browser.Ui_Form): def __init__(self, parent=None): super(Browser, self).__init__(parent) self.setupUi(self) self.setObjectName('Browser') self.setAttribute(QtCore.Qt.WA_DeleteOnClose)-Dave
On Thu, Aug 5, 2010 at 2:39 PM, meljunky br...@meljunky.com wrote:
Trying to get QT Ui file to work in Maya I could use the loadUIcommand for example:import maya.cmds as cmdsdialog = cmds.loadUI(f=r'C:/Python26/Lib/site-packages/PyQt4/examples/designer/calculatorform/calculatorform.ui')cmds.showWindow(dialog)Don't expect the calculator to actually work but the UI opens in Maya.But, I want to be able to edit UI elements so I used uic.compileUi toconvert the file into a Python file in hopes to make method calls toadd and remove UI elements while the window is open.The first four lines are:from PyQt4 import QtCore, QtGuiclass Ui_CalculatorForm(object): def setupUi(self, CalculatorForm):   ...At this point I don't know how to call the Ui_CalculatorForm classmethod setupUi since it needs a different class called CalculatorForm.Thanks in advance.--http://groups.google.com/group/python_inside_maya-- David Moulderhttp://www.google.com/profiles/squish3d
-- 
http://groups.google.com/group/python_inside_maya 



-- http://groups.google.com/group/python_inside_maya -- David Moulderhttp://www.google.com/profiles/squish3d
-- http://groups.google.com/group/python_inside_maya 



-- 
http://groups.google.com/group/python_inside_maya


Re: [Maya-Python] [maya-pymel] variable error when casting python variable to mel

2010-08-05 Thread Jan:
Thank you ! that did the trick !


2010/8/5 damon shelton damondshel...@gmail.com

 mel.eval('filetest -d '+var1 + ';')

 you have to put  around your path in the eval statement



 On Wed, Aug 4, 2010 at 6:15 AM, Red jan@gmail.com wrote:

 Hello all,

 can anyone explain why this does not work ?

 def melVarTest():

var1 = C:/Program Files/Autodesk/Maya2011/bin/plug-ins/
result = mel.eval(string $var1Mel = `python var1`;)
print result

 melVarTest()

 # MelError: Error during execution of MEL script: line 1: name 'var1'
 is not defined

 The reason for doing this is because I want to use the mel filetest
 command and this seemed to me to be the best option.

 I have also tried:

 mel.eval(filetest -d +var1)

 But that instantly crashes maya. (fatal error)


 And when writing it the pymel way it gives me a syntax error that I
 can not figure out

 mel.filetest(var1, d=True)

 # MelError: Error during execution of MEL script: line 1: Invalid call
 to filetest.  Check number and types of arguments expected by the
 procedure.
 # Calling Procedure: filetest, in Command
 #   filetest(var1, d=True) #

 Would anyone be so kind to help me out :)

 Thanks,
 Red

 --
 http://groups.google.com/group/python_inside_maya


  --
 http://groups.google.com/group/python_inside_maya


-- 
http://groups.google.com/group/python_inside_maya

Re: [Maya-Python] Ipymel inside maya gui

2010-08-05 Thread Paul Molodowitch

 I'm new to maya and pymel. I'd like to learn to script maya using
 pymel. I was wondering if it's possible to use ipymel inside the maya
 gui. It seems like it would be a pretty handy tool.


I've looked into this briefly, and unfortunately, I just don't think this is
possible without a lot of work (ie, really getting into the internals of
ipython and mucking around).  If you want to give it a shot, though, it
would be awesome!


 If it is possible how? If it's not possible is there a way to run
 ipymel in a terminal and see the results updated in the maya gui?


This is probably somewhat easier - you'd have to set up a system where you
feed commands into maya through a command port, ala Eclipse Maya, or Maxya.
 I don't know of anyone who's actually done this yet, though...

- Paul

-- 
http://groups.google.com/group/python_inside_maya