in Python Dev (other than cg) , typically standalone apps, i prefer to 
convert .ui files to .py files via uic command and then subclass the view.

in maya python | pymel, i am trying to figure out easy equivalant workflow. 
>From all searches around yesterday including

   - http://nathanhorne.com/
   - http://www.jason-parks.com/artoftech
   
i realized

   1. ppl can directly load / use .ui files, rather then converting to py
   - pros : one step less work ( using uic to convert to py )
      - cons: headache of setting up sip and pyqt , uic etc.. (sometimes 
      hard to find for relevant maya version). in my case, its not working 
      ideally. 50%
   2. ppl can even subclass this ( like i do in standalone version), very 
   impressive
   3. ppl can strangly try to connect (child) this to maya windows . is it 
   necessary. ? not sure.
   - it helps in docking etc?
      - any other advantages?
   

Now i am attaching 3 files
makeCube_ui,py >> relevant .ui file is missing. its from DT. this template 
works
lmRenamer_Tool.py >> relevant .ui also attached. there are two methods in 
py file,
def approach1 >> it works , real ui shows. but i don't know how to get 
controls from ui and bind them function (singals / slots etc) >>its not 
subclassing etc..
def approach2  >> (similar to other py, template modification) but its not 
working, empty black ui shows

btw> i m maya 2014 sp2 , x64.
i downloaded PyQt4-4.10.3-gpl-Py2.7-Qt4.8.5-x64 and installed in maya 
python folder ( C:\Program Files\Autodesk\Maya2014\Python )
i haven't found sip (something).... to replace pyd file>> 
when i tried template approach, (subclassing) i get lot of lengthy log in 
maya script history place i.e
--------------------------------------
# PyQt4.uic.uiparser : pop layout QVBoxLayout verticalLayout # 
# PyQt4.uic.uiparser : pop widget QWidget centralwidget # 
# PyQt4.uic.uiparser : new topwidget Window # 
# PyQt4.uic.uiparser : push QStatusBar statusbar # 
# PyQt4.uic.uiparser : pop widget QStatusBar statusbar # 
# PyQt4.uic.uiparser : new topwidget Window # 
# PyQt4.uic.uiparser : pop widget QMainWindow Window # 
# PyQt4.uic.uiparser : new topwidget None # 
-----------------------------------------------------------------------
lastly, approach 1, window ui shows nicely.  it won't go behind maya ui, as 
i click in viewport
where as even in template script (makeCube_ui.py) it works. but goes back 
(behind) maya windows when i click in viewports .
Final Request
Can someone please explain quick step by step simple way to subclass, or 
share a simple example?
ideally if i can dock to maya view or windows, its extremely useful
huge thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/857916e7-0553-45dc-91c3-33bd974de713%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
#**********************************************
# User Interface creation for Maya
# Written by Us!
from PyQt4 import QtGui, QtCore, uic
from pymel.core import *
import pymel.core as pm
from pymel import *



# Path to the designer UI file*******************************
ui_filename = 'D:\Training\Maya\Digital Tutors - Creating Custom User Interfaces in Maya and Qt Designer\Creating Custom User Interfaces in Maya and Qt Designer\Python Files\makeCube_ui.ui'
form_class, base_class = uic.loadUiType(ui_filename)


#Interface Class**********************************************
class makeCube(base_class, form_class):
        def __init__(self):
                super(base_class, self).__init__()
                self.setupUi(self)
                self.setObjectName('makeCube')
                self.setDockNestingEnabled(True)
                self.connectInterface()


        def connectInterface(self):
            QtCore.QObject.connect(self.makeCube, QtCore.SIGNAL("clicked()"),self.makeCubeWin)

        def makeCubeWin(self):
                mel.eval('global proc makeCube(){CreatePolygonCube;};')
                mel.makeCube()
#main*********************************************************
def main():
        global ui
        ui=makeCube() 
        ui.show()

        
if __name__ == "__main__":
        main()

#import sip
import os,sys,getopt
import maya.cmds as cmds
import maya.OpenMayaUI as mui

#import lmLib
from PyQt4 import QtGui, QtCore, uic
from pymel.core import *
#from pymel import *

#import pysideuic
#from PySide import QtGui, QtCore
#from shiboken import wrapInstance

import maya.OpenMayaUI as apiUI

def approach_01():
	guiFile = lmLib.lmScriptPath + '/lmRenamer_View.ui'
	#print guiFile
	lmRenamerWindow = pm.loadUI(f=guiFile)
	print lmRenamerWindow
	print (type(lmRenamerWindow))
	pm.showWindow(lmRenamerWindow)

def approach_02():
	#Path to the designer UI file
	ui_filename = lmLib.lmScriptPath + '/lmRenamer_View.ui'
	print os.path.exists(ui_filename)
	form_class, base_class = uic.loadUiType(ui_filename)
	global ui
	ui=Interface()
	ui.show()

#Interface class
class Interface(base_class, form_class):
    def __inti__(self):
                super(base_class, self).__init__()
                self.setupUi(self)
                self.serObjetName('windowName')
                self.setDockNestingEnabled(True)
                #sef.connectInterface()
def main():
	#approach_01()
	approach_02()
	

if __name__ == '__main__':
    main()

Attachment: lmRenamer_View.ui
Description: Binary data

Reply via email to