Image on button

EdpaEdpa Posts: 46

Hi!

I try to do button with image. But now have button with image size and picture as too small icon.

I used this script .What should I add? which strings?

var wDlg = new DzDialog;

var wBtn = new DzPushButton(wDlg );

var pixImage = new Pixmap("c:/2016-07-06_180440.png");

wBtn.pixmap = new Pixmap(pixImage );

wDlg.exec()

 

Post edited by Chohole on

Comments

  • EsemwyEsemwy Posts: 577
    edited January 2017

    I think your image just needs to be larger. Also why are you constructing the Pixmap twice?

    var sFilename = aTextureFiles[i];var button1 = new DzRadioButton( wVbgLayer );button1.pixmap = new Pixmap( sFilename );

    I don't have a push button example handy, but DzRadioButton should be the same.

    Post edited by Esemwy on
  • EsemwyEsemwy Posts: 577

    I take it back. This must be something peculiar to DzPushButton. It looks like a bug to me.

  • hphoenixhphoenix Posts: 1,335

    I think you are both thinking a DzPushButton's icon is for image purposes.....it's supposed to be the 'down arrow' for buttons that display a set of options.  Position and size are GUI style controlled.  Look at the definition of the Qt class it wraps (QPushButton) here:  http://doc.qt.io/qt-4.8/qpushbutton.html

    I'm not sure what DS uses for buttons with non-icon style images on them.  It may be a built-in custom widget that would have to be loaded using DzUiLoader....

     

     

  • EdpaEdpa Posts: 46

    Thanks guys!

    I thought before about DzUiLoader :) 

    But I do not know how I can connect this with the action,with my function.

    I tried this code, but it does not work

    var loader = new DzUiLoader();

    var dialog = new DzDialog();

    var dialogWgt = loader.load("C:/test.ui",dialog);

    connect( dialogWgt, "clicked()", myFunction );

    dialog.exec();

  • EsemwyEsemwy Posts: 577
    edited February 2017
    Edpa said:

    Thanks guys!

    I thought before about DzUiLoader :) 

    But I do not know how I can connect this with the action,with my function.

    I tried this code, but it does not work

    var loader = new DzUiLoader();

    var dialog = new DzDialog();

    var dialogWgt = loader.load("C:/test.ui",dialog);

    connect( dialogWgt, "clicked()", myFunction );

    dialog.exec();

    I think what you need to do is something like (**untested**):

    var dialog = new DzDialog();var dialogWgt = loader.load("C:/test.ui",dialog);buttonWgt = dialog.findChildOfWidget("theOkButton"); # Find the button by its nameconnect( buttonWgt, "clicked()", myFunction );dialog.exec();

     

    Post edited by Esemwy on
  • EdpaEdpa Posts: 46

    Hi, Esemwy!

    Your script is running great. Thank you very much. Button name I found in my UI file (my widget) and replace your name  theOkButton.

    Hurrah, now I can create any widgets! yes

    The script looks completely

    var loader = new DzUiLoader();

    var dialog = new DzDialog();

    var dialogWgt = loader.load("C:/test.ui",dialog);

    buttonWgt = dialog.findChildOfWidget("toolButton"); // Find the button by its name

    connect( buttonWgt, "clicked()", myFunction );

    dialog.exec();

    A fragment of UI file with Button name

     <widget class="QToolButton" name="toolButton">
       <property name="geometry">

  • Hi  guys!

    I wrote about Vertical slider http://www.daz3d.com/forums/discussion/73311/vertical-slider#latest

    I thought to use the UI file too.
    After example of Esemwy, I tried to come back to this method. But I did not succeed ... Have you tried to do the slider widget?

    If yes, How do you connect the slider with actions? Which signals you used? 

  • EdpaEdpa Posts: 46

    I see strange visualization of the vertical slider in the DAZ. I think that DAZ not support it now. Try to use the QT scrollbar instead of slider. Parameters are similar.

  • YudinEdYudinEd Posts: 90
    edited March 2017

    Other version without UI file - Label on the button

    var wDlg = new DzDialog;var wBtn = new DzPushButton(wDlg );var Label=new DzLabel(wBtn)var pixImage = new Pixmap("c:/image.jpg");Label.pixmap = new Pixmap(pixImage );// Button size must have image size. My image size = 80,100wBtn.width=80wBtn.height=100 wDlg.exec()

     

    Post edited by YudinEd on
  • TotteTotte Posts: 13,517

    Looking at the docs there is a ButtopStyle Object that is not documented, I guess that has something to do with this....

     

  • TotteTotte Posts: 13,517
    Yudined said:

    Other version without UI file - Label on the button

    var wDlg = new DzDialog;var wBtn = new DzPushButton(wDlg );var Label=new DzLabel(wBtn)var pixImage = new Pixmap("c:/image.jpg");Label.pixmap = new Pixmap(pixImage );// Button size must have image size. My image size = 80,100wBtn.width=80wBtn.height=100 wDlg.exec()

     

    Downside is that the image is not default adjusted to pushed/non pushed state, but I like this workaround for the time being

     

  • YudinEdYudinEd Posts: 90
    edited April 2017

    No problem . Simple example :)

    var wDlg = new DzDialog;var wBtn = new DzPushButton(wDlg );var Label1=new DzLabel(wBtn)var Label2=new DzLabel(wBtn)var pixImage1 = new Pixmap("c:/image.jpg");Label1.pixmap = new Pixmap(pixImage1 );var pixImage2 = new Pixmap("c:/img.jpg");Label2.pixmap = new Pixmap(pixImage2 );Label2.hide()connect(wBtn,"clicked()", ButtonClicked)// signals too  "pressed()" or "released()"// Button size must have image size. My image size = 80,100wBtn.width=80wBtn.height=100 wDlg.exec()function ButtonClicked(){Label2.show	()}

    You can control clicks. I usually use the function (for 2 clicks-  even or odd number)

    var a =0;if ( a&amp;1 ) {   false // even click - 1th image}else {   true; //odd click - second image}

     

    Post edited by YudinEd on
  • cridgitcridgit Posts: 1,757
    edited May 2022

    Redacted

    Post edited by cridgit on
  • YudinEdYudinEd Posts: 90

    I only write the tested scripts. The code works. Check the path to your picture and its name  and slash (correctly  / )

    cheeky

  • cridgitcridgit Posts: 1,757
    edited May 2022

    Redacted

    Post edited by cridgit on
Sign In or Register to comment.