Below is an example demonstrating how to construct a simple dialog with a composite image, name it so its position is stored uniquely from other script constructed dialogs, and size it according to the image.
// DAZ Studio version 4.10.0.120 filetype DAZ Script // Define an anonymous function; // serves as our main loop, // limits the scope of variables (function( sFileName1, sFileName2 ){ /*********************************************************************/ // String : A function for retrieving a translation if one exists function text( sText ) { // If the version of the application supports qsTr() if( typeof( qsTr ) != "undefined" ){ // Return the translated (if any) text return qsTr( sText ); } // Return the original text return sText; }; /*********************************************************************/ // Define the template for What's This text var sWhatsThis = "<b>%1</b><br/><br/>%2"; // Create a basic dialog var wDlg = new DzBasicDialog(); // Get the wrapped widget for the dialog var oDlgWgt = wDlg.getWidget(); // Set the title of the dialog wDlg.caption = "My Image"; // Strip the space for a settings key var sKey = wDlg.caption.replace( / /g, "" ) + "Dlg"; // Set an [unique] object name on the wrapped dialog widget; // this is used for recording position and size separately // from all other [uniquely named] DzBasicDialog instances oDlgWgt.objectName = sKey; // Create images to be used for compositing var oImage1 = new Image( sFileName1 ); var oImage2 = new Image( sFileName2 ); // Define the text we want to draw over the image var sText = String("Copyright (c) %1 %2. All rights reserved.") .arg( (new Date()).getFullYear() ) .arg( App.getCurrentAuthor().name ); // Define the color of the text var oColor = new Color( 255, 255, 255, 200 ); // Define which flags to use for the text var nFlags = DzWidget.AlignHCenter|DzWidget.TextWordWrap; // Define the font to use for the text var oFont = new Font(); oFont.family = "Helvetica"; oFont.pixelSize = 10; // Get the size of the text var sizeText = oFont.size( sText, nFlags ); // Create a (readOnly) combo edit for choosing a compositing method var wCompositeCmb = new DzComboEdit( wDlg ); wCompositeCmb.readOnly = true; wCompositeCmb.addItem( "compositeOver" ); wCompositeCmb.addItem( "compositeIn" ); wCompositeCmb.addItem( "compositeOut" ); wCompositeCmb.addItem( "compositeAtop" ); wCompositeCmb.addItem( "compositeXor" ); wCompositeCmb.addItem( "compositePlus" ); wCompositeCmb.addItem( "compositeMultiply" ); wCompositeCmb.addItem( "compositeScreen" ); wCompositeCmb.addItem( "compositeOverlay" ); wCompositeCmb.addItem( "compositeDarken" ); wCompositeCmb.addItem( "compositeLighten" ); wCompositeCmb.addItem( "compositeColorDodge" ); wCompositeCmb.addItem( "compositeColorBurn" ); wCompositeCmb.addItem( "compositeHardLight" ); wCompositeCmb.addItem( "compositeSoftLight" ); wCompositeCmb.addItem( "compositeDifference" ); wCompositeCmb.addItem( "compositeExclusion" ); // Add the combo edit to the dialog wDlg.addWidget( wCompositeCmb ); // Create a pixmap for the image var pixDynamic = new Pixmap(); // Create a label and assign a pixmap var wDynamicLbl = new DzLabel( wDlg ); //wDynamicLbl.pixmap = pixDynamic; // Add the label to the dialog wDlg.addWidget( wDynamicLbl ); // Make a connection to an anonymous function that triggers when the text of // the combo edit changes; the 'this' object is the pixmap being modified connect( wCompositeCmb, "textChanged(const QString&)", pixDynamic, function( sCompositeMethod ) { var rectText; // If the application version is 4.10.0.120 or newer if( App.version64 >= 0x0004000a00000078 ){ // Composite the first and second image imgComposite = oImage1[sCompositeMethod]( oImage2 ); // If the application version is 4.10.0.121 or newer if( App.version64 >= 0x0004000a00000079 ){ // Draw the text over the image rectText = imgComposite.drawText( (imgComposite.width/2) - (sizeText.width/2), (imgComposite.height/2) - (sizeText.height/2), sText, oFont, oColor, nFlags ); } // Convert the image to a pixmap this.fromImage( imgComposite ); // If the application version is older } else { // Convert the image to a pixmap this.fromImage( oImage1 ); } // Set the pixmap to display in the label wDynamicLbl.pixmap = this; } ); // Set the text to the first composite method wCompositeCmb.text = wCompositeCmb.items()[0]; // Get the minimum size of the dialog var sizeHint = oDlgWgt.minimumSizeHint; // Set the fixed size of the dialog wDlg.setFixedSize( sizeHint.width, sizeHint.height ); // Set the text on the accept button wDlg.setAcceptButtonText( text( "&Close" ) ); // Hide the cancel button wDlg.showCancelButton( false ); // Display the dialog wDlg.exec(); // Finalize the function and invoke })( "D:/temp/1.png", "D:/temp/2.png" );