On Sat, Oct 21, 2017 at 5:37 PM jettam <[email protected]> wrote:

> I am building a UI. When the button is checked the code should call a
> module called "makeRobotBug" and an object will be placed into my scene.
> It's not working and I am not getting any error messages either, which is
> kind of strange.
>

QPushButton is not checkable by default. You have to enable that feature:

self.pBtn_makeRobot = QtWidgets.QPushButton("MAKE ROBOT")
self.pBtn_makeRobot.setCheckable(True)

Until you do that, your slot is going to be called but it will always
return False for isChecked()


> Notice I import makeRobotBug at the to of the script. Then I call it in
> the createGeometry(self) function.
>
>
> import os
> import functools
> from PySide2 import QtWidgets, QtCore, QtUiTools, QtGui
> from shiboken2 import wrapInstance
> import maya.cmds as mc
> import maya.OpenMayaUI as omui
> *import** makeRobotBug*
>
> '''
> import thisModule
> reload (thisModule)
> thisModule.run()
> '''
>
> 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)
>
>         #self.resize(400, 300)
>
>         ##  From Pysideuic compiled code goes here
>         #############################################################
>         self.gridLayout = QtWidgets.QGridLayout()
>
>         self.verticalLayout = QtWidgets.QVBoxLayout()
>
>         self.pBtn_makeRobot = QtWidgets.QPushButton("MAKE ROBOT")
>
>         self.verticalLayout.addWidget(self.pBtn_makeRobot)
>         self.gridLayout.addLayout(self.verticalLayout, 0, 0, 1, 1)
>         ##############################################################
>
>         self.setWindowTitle("WIN CONTROLLED IN PYTHON")
>         self.setLayout(self.gridLayout)
>         self.show()
>         self.makeConnections()
>
>     def makeConnections(self):
>         ''' connect events in out UI '''
>         self.pBtn_makeRobot.clicked.connect( self.createGeometry )
>
>     def createGeometry(self):
>         print("Create geometry pressed")
>
>         if self.pBtn_makeRobot.isChecked():
>             *makeRobotBug**.makeRobotBug()*
>
> --
> 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/f5f84975-7091-4d77-827d-8acfdd3fb5c4%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/f5f84975-7091-4d77-827d-8acfdd3fb5c4%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/CAPGFgA0Kb7Kys_wgch2bZP8eOc%3Dc48eU2-__t-w336NXHS%2BYdA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to