UI Button is not calling my module.

45 views
Skip to first unread message

jettam

unread,
Oct 21, 2017, 12:36:58 AM10/21/17
to Python Programming for Autodesk Maya
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. 

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()

Justin Israel

unread,
Oct 21, 2017, 1:04:54 AM10/21/17
to python_in...@googlegroups.com
On Sat, Oct 21, 2017 at 5:37 PM jettam <justin...@gmail.com> 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()

--
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/f5f84975-7091-4d77-827d-8acfdd3fb5c4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

jettam

unread,
Oct 21, 2017, 1:36:12 AM10/21/17
to Python Programming for Autodesk Maya
This documentation is confusing. I got it to work, only because you showed me, the documentation is confusing. 

How would I go about implementing the .animateClick([msec=100])
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

jettam

unread,
Oct 21, 2017, 3:20:07 AM10/21/17
to Python Programming for Autodesk Maya

Justin Israel

unread,
Oct 21, 2017, 3:31:55 AM10/21/17
to python_in...@googlegroups.com
It's just a method. You can call it if that is your goal. 

button.animateClick()

The [msec] indicates that an optional millisecond argument can be given as a delay for the click release 

button.animateClick(1000)

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

--
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/0a533217-a133-4280-88b0-44e860f26b1b%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages