DzUserDrawStyle - Get the pixmap into a comboBox?
bigD3d
Posts: 75
Hello all,
I just posted part one of this on how to get the list of user draw styles from the viewport manager and then shortly after, figured that out.
Now i'd like to know if anyone knows how to get the icon/pixmap for those into a combo box in a script?
I am getting the getDescription() text into my combo box (attachment 1) but am curious if I can make my script look like the viewport screen (attachment two).
Code to get the description is:
var oViewportMgr = App.getInterface().getViewportMgr(); var numUserDrawStyles = oViewportMgr.getNumUserDrawStyles(); for(i=0; i < numUserDrawStyles ; i++) { drawStyleTypeComboBox.addItem(oViewportMgr.getUserDrawStyle(i).getDescription()); }
Any help is greatly accpreciated!
Script ComboBox.jpg
424 x 405 - 24K
Draw Styles.jpg
310 x 323 - 41K
Post edited by bigD3d on
Comments
Would you perhaps get the drawstyle action from ActionMgr, then the icon from the action?
Thanks for the reply Richard.
I probably should have mentioned in the original post - I believe I can get the pixmap of the icon of the draw style from the same DzUserDrawStyle object, but haven't verified it.
I am *assuming* this will return the little icon that is in the dropdown on the viewport next to the drawstyle name/description. When I change my code to use .getPixmap() my drop down list has "object [Object]". I have yet to try to view the icon to see that it is really it.
The documentation has this for the object description:
Any draw styles which should be available to the user for selecting need to be derived from this class.
Subclasses must implement the getPixmap() to return the icon that will be displayed in the viewport drop-down list,
and getDescription() to return the text that accompanies the icon.
So assuming that is correct, the real question is - is there a combobox object available in scripting that can show the icon and description together? I've been assuming (again) that every UI object in Daz Studio can be created from a script, but I don't see anything yet that would do a combobox with an icon/image and text.
Is there another kind of UI object instead of a combobox I should be looking for?
thanks again
If you see object [Object] that usually means that the wrong item has been passed - possibly the whole object when only one of its members is required. If you pass the wrong type of object entirely that usually geenrates a complaint that the function doesn't match any of the overloaded signatures available.
When I look at the documentation for DzComboBox ( http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/combobox_dz ) I see it's a wrapper for QComboBox. The QComboBox object appears to support icons and text in the list item, but I can't create an object of that type, like say I can for QImage. Any idea how to access/use the QComboBox via script?
Alternatively, I see DzListView can take DzListViewItems, and the DzListViewItems can have a pixmap and text. But I haven't yet figured out how to make these object show in my dialog correctly (and not sure if they are the appropriate control either...).
thanks
I don't think that is possible for DAZ Script. I believe the only way to access QComboBox is by utilizing the Daz SDK.
You could, however, design the entire widget/dialog using the QtDesigner app (designer.exe) where DAZ is installed. You can then create a DzUILoader object, load it, and show it.
DzUILoader
DzWidget
You could also add a pixmap loading from an image file with a transparent background. You'd just have to resize it, I believe. I haven't really worked with Pixmap so good luck :)
Dafa,
thanks very much for this. I have used the QTDesigner as a starting point to layout the basics of my dialogs and puchased Dialog Design ( https://www.daz3d.com/dialog-design ) to have most of the controls i've used converted into their Dzxxx objects in script. I vaguely recall the DzUiLoader when researching on how to get started in scripting and don't recall why I didn't use/try it - and since completely forgot about it.
I have a couple of questions on this too:
* Once you have oWidget loaded, is that the actual dialog object, with the QComboBox as a child object?
* If yes, how do you access the QComboBox object for scripting? For instance to grab which selection the user picked, or add/remove selection choices dynamically.
* I see in DzUiLoader reference a "createWidget()" method which references a QObject in the method signature. Do you use it to bypass loading the whole dialog and create the QComboBox from "within" the objects of the *.ui file?
I hope those questions make sense. I'll definately mess around with this after work tonight.
thanks again
Yes, it returns a DzWidget with QComboBox instead of DzComboBox.
This is where I think the UILoader option comes to an end. I was curious my self. So, you can access all objects of the parented DzWidget by doing this:
You could then do a for loop to find the QComboBox or findChildOfWidget(). Unfortunately, because you wanted a QComboBox, it is unclear what properties or methods you can access. For example, in the QT documentation, you should be able to call count(), nope. So then I thought maybe it can be called by some of the methods available in the Daz Documentation, like getWidget(), nope. You'll get a TypeError stating they're not functions. However, you can get properties from the QComboBox which is weird. It's very confusing. Also, the objects do not inherit DzWidget.
At this point, I'm not even sure. createWidget() is documented to return a DzWidget but instead returns a QWidget. I do know that createWidget() isn't used to load any .ui files.
Sorry I couldn't be much help.
I'll see what I can do messing around with all this tonight. It's really frustrating that the Dz wrapper doesn't fully support the underlying QComboBox. This seems like it would be a very nice option to set some icons and improve people's script projects, especially for those going to be sold on the site.
But it's starting to lean towards having no icons in my DzComboBox and just use the draw style descriptions. I did make a DzListView with DzListViewItems which allowed the icon to be in a column, but that takes up alot of room on the dialog.
thanks again for all the info.
Rob suggests using a DzPushButton in the dialogue, then when it signals it's been pushed show a DzPopupMenu which can show the Pixmaps as well as the label
Richard, in your opinion, what is the discriminant that determines which questions a dev will take the time to answer, and which ones he will ignore?
I would imagine there are many factors, from available time to complexity of the question, but I'm sure the way in which the question is asked is a factor.
Richard, thanks for this. I will definately try this approach.
Apparently you have to insert one of the elements into the menu item, then change the other - you can't just insert both pixmap and text. This is an issue that is being addressed, as is the documentation of DzPushButton.
HTH