Isotropix Forums

How can I get Clarisse Standard Icon Image into PyQt widget

Clarisse Scripting related topics

How can I get Clarisse Standard Icon Image into PyQt widget

Unread postby neonika » Thu Feb 01, 2018 2:56 am

Hi,

I'm trying to display the standard Clarisse icon images against the respective item names in my PyQt widget. For eg: If my QTreeWidget lists an item of type "LayerImage", I'd like to pull the same icon for that item as displayed in Clarisse's Browser window.

Here's an example piece of code:

Code: Select all
item = ix.get_item("project://renderPasses/EXAMPLE_BEAUTY/EXAMPLE_BEAUTY_LAYER")
icon = item.get_item_icon()
imgData =  icon.get_image().get_data()


I was hoping to convert 'imgData' into a QPixmap object in PyQt. But haven't had any success because the expected argument type in Qt is QByteArray. And I don't know how to handle the data type for imgData. If I run something like this:
Code: Select all
pixMap = QtGui.QPixmap()
pixMap.loadFromData(imgData)


I get this error:
argument 1 has unexpected type 'SwigPyObject'

Any help is greatly appreciated!
neonika
 
Posts: 2
Joined: Mon Aug 07, 2017 8:48 am

Re: How can I get Clarisse Standard Icon Image into PyQt wid

Unread postby bvaldes » Thu Feb 08, 2018 9:52 am

Hi,

First of all sorry for the last reply. We tried to figure out how to get the binaries data of an icon but it's not possible.
The issue is that python is not able to interpret the result of get_data() function. We tried to find a way to get the data in the right format and convert it but without success.

I have added a feature request(#8010) to be able to do that. Sorry to can't help you, you won't be able to add the icon to your tree for now.

Regards
Benoit VALDES
Isotropix
Clarisse QA
User avatar
bvaldes
 
Posts: 315
Joined: Mon Sep 26, 2016 10:44 am

Re: How can I get Clarisse Standard Icon Image into PyQt wid

Unread postby neonika » Wed Feb 28, 2018 1:40 am

Hi Benoit,

Thank you so much for clarifying that! And for adding the feature request. It would be great to have :)

Appreciate you looking into it.

Best Regards,
-Ruhi
neonika
 
Posts: 2
Joined: Mon Aug 07, 2017 8:48 am

Re: How can I get Clarisse Standard Icon Image into PyQt wid

Unread postby Braden99 » Tue Dec 11, 2018 3:20 am

Yes this would be great, even better if the icon data could be returned directly as QPixmap.
But I understand for now Clarisse doesn't use Qt for app itself.

Otherwise the app could ship with png icons as an alternative, or a simple utility to view icons and save them (like Maya shelf tool) to some basic formats.
Braden99
 
Posts: 45
Joined: Mon Jan 08, 2018 3:05 am

Re: How can I get Clarisse Standard Icon Image into PyQt wid

Unread postby Braden99 » Thu Jan 17, 2019 11:59 am

The GuiIcon constructor of Clarisse cannot accept a file path either, for example.

item = ix.get_item('project://scene/some_item')
class_name = item.get_class_name()
class_factory = ix.application.get_factory().get_classes().exists(class_name)
icon = ix.api.GuiIcon('D:\Desktop\SomeIcon.png')
class_factory.set_icon(icon)


Results in this error.
this = _gui.new_GuiIcon(*args)
TypeError: in method 'new_GuiIcon', argument 1 of type 'unsigned char const **'


The docs have this signature
GuiIcon (const unsigned char **data)
Braden99
 
Posts: 45
Joined: Mon Jan 08, 2018 3:05 am

Re: How can I get Clarisse Standard Icon Image into PyQt wid

Unread postby sam » Thu Jan 17, 2019 12:59 pm

The constructor you mention doesn't accept a string but an array of bytes (hence the unsigned before char). It is used to set the actual image data based our proprietary image ressource data in our SDK.
Sam Assadian
Isotropix
CEO/Founder
User avatar
sam
 
Posts: 1252
Joined: Fri Jan 25, 2013 11:33 pm


Return to Scripting