images for buttons

73 views
Skip to first unread message

Todd Widup

unread,
Jun 19, 2015, 11:41:28 PM6/19/15
to python_in...@googlegroups.com
hey guys

I have been trying to create an image button, but every way I found a suggestion on how to try doesn't seem to work. 

        self.cube_btn = QtGui.QPushButton("Cube")
        icon = QtGui.QIcon("{0}winPub_PUB.png".format(self.icons))
        self.cylinder_btn.setIcon(icon)


ive tried that and I have tried setting the style sheet background-image and neither work. 

any suggestions?

--
Todd Widup
Creature TD / Technical Artist
to...@toddwidup.com
todd....@gmail.com
www.toddwidup.com

Kurian O.S

unread,
Jun 20, 2015, 12:10:00 AM6/20/15
to python_in...@googlegroups.com
self.cylinder_btn.setIcon(icon) to self.cube_btn.setIcon(icon) ?

--
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/CABBPk36-VSG0bzWig4ap1aQyBsZEKW%2BvzWcaveHWO-oLOXxFqw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.



--
--:: Kurian ::--

Todd Widup

unread,
Jun 20, 2015, 12:29:23 AM6/20/15
to python_in...@googlegroups.com
I have both   Just copied paste was wrong 

Sent from my iPhone

Kurian O.S

unread,
Jun 20, 2015, 12:33:53 AM6/20/15
to python_in...@googlegroups.com
self.cube_btn = QtGui.QPushButton("Cube")
btIcon = QtGui.QPixmap("{0}winPub_PUB.png".format(self.icons))
self.cube_btn .setIcon(QtGui.QIcon(btIcon ))


For more options, visit https://groups.google.com/d/optout.



--
--:: Kurian ::--

Todd Widup

unread,
Jun 20, 2015, 2:32:15 PM6/20/15
to python_in...@googlegroups.com
awesome..thanks...that's finally working.  I


For more options, visit https://groups.google.com/d/optout.



--

Todd Widup

unread,
Jun 22, 2015, 11:43:44 PM6/22/15
to python_in...@googlegroups.com
ok, so the image shows up, but I need to control the size, only option I have found is the scale method, which looks to need 2QtInt but its not scaling the image. 

Justin Israel

unread,
Jun 23, 2015, 12:17:05 AM6/23/15
to python_in...@googlegroups.com
Are you looking for  QPushButton.setIconSize(QSize) ? Or are you trying to transform the source image before setting it on the button?

damon shelton

unread,
Jun 23, 2015, 12:20:23 AM6/23/15
to python_in...@googlegroups.com
QtGui.QPushButton.setIconSize(QtCore.QSize(width, height)) 


Todd Widup

unread,
Jun 23, 2015, 12:25:48 AM6/23/15
to python_in...@googlegroups.com
hey Damon,... thanks...I swore I had tried that already, but that is working....I think I just past ints in rather than QSize  and thanks Justin, always appreciate all the help here. 


For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages