PNG icons and GridLayout

31 views
Skip to first unread message

Chris C

unread,
May 6, 2019, 11:18:29 PM5/6/19
to Python Programming for Autodesk Maya
Hi all,

I have started a small project to learn more about python and programming. Total beginner but just thought i give it a shot and get help from this group.


I have created a material library interface just using python within maya. Just like the image below.

I am trying to find a way to search for PNG thumbnails specified by the material library path and add those PNG files in the Grid Layout separating them into categories as listed in the file explorer and also in the interface.


I have used just a normal button as a test and placeholder for the PNG images.

I had a look at many examples and tried but i cannot seem to get it to work. If anyone has ideas or can share their knowledge would be a great help. 



matLibBrowser.jpg





Marcus Ottosson

unread,
May 7, 2019, 2:22:55 AM5/7/19
to python_in...@googlegroups.com

Hi Chris, and welcome to the mailing list!

Would assigning the PNG directly to your QPushButton work for you?

from Qt import QtWidgets, QtGui, QtCore

button = QtWidgets.QPushButton()
pixmap = QtGui.QPixmap(r"c:\users\manima\Desktop\syrian.png")
button.setIcon(pixmap)
button.setIconSize(QtCore.QSize(100, 100))
button.show()

image.png


--
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/04c2a800-9669-46e3-b7ec-fa575059c5b8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Chris C

unread,
May 7, 2019, 3:05:39 AM5/7/19
to Python Programming for Autodesk Maya
Hi Marcus,

Thanks for message !

I kind of got it working with just scanning just the main directory with this code below : 
It only scans on the 'matLibPath' folder for PNG icons. I am trying to make it scan for subfolders. Anyone have suggestions scanning subfolders with 'listdir' would be greatly appreciated ! 

Below is the result of the UI

-------------------------------------------------

matLibPath = "D:\CCMatlib\Vray" 
customPathItems = listdir(matLibPath)

def popUI(*args):
    for item in customPathItems:
        if item.endswith("_icon.png"):
            cmds.iconTextButton(l = item, p = 'gridLay', i = matLibPath + "/" + item, w = 64, h = 64)

------------------------------------------------------------------------

matlib2.JPG




On Tuesday, 7 May 2019 15:22:55 UTC+9, Marcus Ottosson wrote:

Hi Chris, and welcome to the mailing list!

Would assigning the PNG directly to your QPushButton work for you?

from Qt import QtWidgets, QtGui, QtCore

button = QtWidgets.QPushButton()
pixmap = QtGui.QPixmap(r"c:\users\manima\Desktop\syrian.png")
button.setIcon(pixmap)
button.setIconSize(QtCore.QSize(100, 100))
button.show()

image.png


On Tue, 7 May 2019 at 04:18, Chris C <kuriku...@gmail.com> wrote:
Hi all,

I have started a small project to learn more about python and programming. Total beginner but just thought i give it a shot and get help from this group.


I have created a material library interface just using python within maya. Just like the image below.

I am trying to find a way to search for PNG thumbnails specified by the material library path and add those PNG files in the Grid Layout separating them into categories as listed in the file explorer and also in the interface.


I have used just a normal button as a test and placeholder for the PNG images.

I had a look at many examples and tried but i cannot seem to get it to work. If anyone has ideas or can share their knowledge would be a great help. 



matLibBrowser.jpg





--
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_maya+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages