Hey all, I'm trying to get started learning PySide. In my below example, I
know I should technically be using classes and probably don't have things
constructed exactly right, but hey, baby steps.
Anyway, I imagine this is pretty simple. I have a SpinBox that can
contain integers, and a button that should preform a function when played.
Only I need to put the value of the SpinBox into the function as an
argument which I'm having a hard time figuring out. It seems like
QtGui.QSpinBox().value() gets the value of the SpinBox but I don't know how
to send that back to the function as an argument. The button in question
is several lines from the bottom. I've scoured the internet for help, but
maybe I don't even know what I'm actually looking for. Any help would be
hugely appriciated!
from PySide import QtGui
import maya.OpenMayaUI as mui
import shiboken
import pymel.core as pm
import maya.cmds as cmds
def get_maya_window():
pointer = mui.MQtUtil.mainWindow()
return shiboken.wrapInstance(long(pointer), QtGui.QWidget)
###---Functions---###a
def move_keys(spinBoxVal):
curSel = pm.selected()
pm.keyframe(curSel, relative=True, tc=(spinBoxVal))
####---Window code---###
windowName = "myWin"
#check for window
if cmds.window("myWin", exists = True):
cmds.deleteUI("myWin", wnd=True)
#window
parent = get_maya_window()
window = QtGui.QMainWindow(parent)
window.setObjectName(windowName)
window.setWindowTitle("Anim Tools")
#font
font = QtGui.QFont()
font.setPointSize(12)
font.setBold(True)
#main widget
mainWidget = QtGui.QWidget()
window.setCentralWidget(mainWidget)
#Translate layout
translateLayout = QtGui.QHBoxLayout()
#Vertical layout
verticalLayout = QtGui.QVBoxLayout(mainWidget)
parent = get_maya_window()
verticalLayout.addLayout(translateLayout)
#Label
label = QtGui.QLabel("Shift Value:")
translateLayout.addWidget(label)
#SpinBox
spinBox = QtGui.QSpinBox()
spinBox.setRange(0,10000)
spinBox.setValue(50)
translateLayout.addWidget(spinBox)
#button
button = QtGui.QPushButton("Shift")
verticalLayout.addWidget(button)
button.setMinimumSize(100,40)
button.setFont(font)
button.setMaximumSize(400,40)
button.setStyleSheet("background-color:rgb(59,248,130); color: black")
button.clicked.connect(move_keys)#
<---------This is where I don't know what to do!
#show window
window.show()
--
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/88c51f8c-e2fa-4142-9a18-fd47f321522f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.