Is anyone able to get a simple QIcon to show up with pyside? Button or QlistWidget or anything?
Here is my code straight from Autodesk help, with the icon additions…
from PySide import QtGui
import MaxPlus
class _GCProtector(object):
widgets = []
def make_cylinder():
obj = MaxPlus.Factory.CreateGeomObject(MaxPlus.ClassIds.Cylinder)
obj.ParameterBlock.Radius.Value = 10.0
obj.ParameterBlock.Height.Value = 30.0
node = MaxPlus.Factory.CreateNode(obj)
time = MaxPlus.Core.GetCurrentTime()
MaxPlus.ViewportManager.RedrawViews(time)
return
app = QtGui.QApplication.instance()
if not app:
app = QtGui.QApplication([])
def main():
MaxPlus.FileManager.Reset(True)
w = QtGui.QWidget()
w.resize(250, 100)
w.setWindowTitle(‘Window’)
_GCProtector.widgets.append(w)
w.show()
main_layout = QtGui.QVBoxLayout()
label = QtGui.QLabel("Click button to create a cylinder in the scene")
main_layout.addWidget(label)
cylinder_btn = QtGui.QPushButton("Cylinder")
#-------- addition to get a simple icon to work
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap("H:/3D/0-Library/Default/default_icon.jpg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
cylinder_btn.setIcon(icon)
#--------
main_layout.addWidget(cylinder_btn)
w.setLayout(main_layout)
cylinder_btn.clicked.connect(make_cylinder)
if name == ‘main’:
main()