Using pyside2uic I converted my QtDesigner.  It's super simple for my 
testing Just one pushbutton.

I can get it to launch in Maya. Great! But its small and not centered to 
the maya window.  I tried adding some code at the bottom that is suppose to 
scale it to 350x375 and center it. But its not working. 



# Loading a Qt Designer UI file and editing the loaded widget

import os
from PySide2 import QtWidgets, QtCore, QtUiTools, QtGui
from shiboken2 import wrapInstance
import maya.cmds as mc
import maya.OpenMayaUI as omui

def getMayaWindow():
 ''' pointer to the maya main window '''
 ptr = omui.MQtUtil.mainWindow()
 if ptr:
 return wrapInstance(long(ptr), QtWidgets.QMainWindow)

def run():
 ''' builds our UI '''
 global win
 win = GeometryGenerator(parent=getMayaWindow())
 #win.show()

class GeometryGenerator(QtWidgets.QDialog):
 
 def __init__(self,parent=None):
 super(GeometryGenerator,self).__init__(parent)


 # From Pysideuic compiler

 self.gridLayout = QtWidgets.QGridLayout()
 self.pushButton_A = QtWidgets.QPushButton()
 self.gridLayout.addWidget(self.pushButton_A, 0, 0, 1, 1)

 self.setWindowTitle(" WIN CONTROLLED IN PYTHON ")
 self.setLayout(self.gridLayout)
 self.show()




 # maya win dimensions
 parentWidth = parent.width()
 parentHeight = parent.height()

 guiWidth = 350
 guiHeight = 375

 posX = parentWidth * 0.5 - (guiWidth * 0.5) + parent.x() 
 posY = parentHeight * 0.5 - (guiHeight * 0.5) + parent.y() 

 self.ui.setGeometry(posX, posY, guiWidth, guiHeight)




      


-- 
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 python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/c7488c6d-4316-4b62-849c-e0cff6acae20%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to