Hello everyone,
I'm having a problem building an interface with pyside,
I'm trying to have a picture of the face of my character, and on top of it, i want to place some small buttons to select the controls.
...it seems I can't place buttons in an absolute space when I'm inside a layout, ...does anyone has an idea how to do it? is there another way to do it?
Thanks
E
This is my sample code:
import traceback
from PySide import QtCore
from PySide import QtGui
from shiboken import wrapInstance
import maya.cmds as mc
import maya.OpenMayaUI as omui
def maya_main_window():
main_window_ptr = omui.MQtUtil.mainWindow()
return wrapInstance(long(main_window_ptr), QtGui.QWidget)
class TestUi(QtGui.QDialog):
def __init__(self, parent=maya_main_window()):
super(TestUi, self).__init__(parent)
def create(self):
#Set up the UI prior to display
self.setWindowTitle("TestUi")
self.setWindowFlags(QtCore.Qt.Tool)
self.create_controls()
self.create_layout()
def create_controls(self):
#Create the widgets for the dialog
labelImage = QtGui.QPixmap("/Desktop/testFace.jpg")
self.image_label = QtGui.QLabel(" ")
self.image_label.setPixmap(labelImage)
self.push_button = QtGui.QPushButton("")
self.push_button.setFixedHeight(12)
self.push_button.setFixedWidth(12)
self.push_button.setStyleSheet("background-color:red;");
self.push_button.move(10,10)
def create_layout(self):
#Create the layouts and add widgets
main_layout = QtGui.QVBoxLayout()
main_layout.setContentsMargins(6, 6, 6, 6)
main_layout.addWidget(self.image_label)
main_layout.addWidget(self.push_button)
main_layout.addStretch()
self.setLayout(main_layout)
if __name__ == "__main__":
try:
test_ui.deleteLater()
except:
pass
test_ui = TestUi()
try:
test_ui.create()
test_ui.show()
except:
test_ui.deleteLater()
traceback.print_exc()