On Thu, Oct 19, 2017 at 12:18 PM jettam <[email protected]> wrote:
> 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.
>
I can't tell from your code, because its incomplete, but it looks like you
should be calling the size operation on "self" instead of "self.ui". If
"self.ui" is constrained to the main dialog then the resize and move wont
do anything. You want to resize and move your top level dialog.
>
>
>
> # 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/c7488c6d-4316-4b62-849c-e0cff6acae20%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/c7488c6d-4316-4b62-849c-e0cff6acae20%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
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/CAPGFgA3DdiKte_8%3D1%2BAs9FHJB%2BcAYG4Zii05tCGVGCZ39YZZwA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.