Using a Palette to change DzWidget colours

HowieFarkesHowieFarkes Posts: 585

Using a Palette to change DzWidet colours has anyone made this work and have some code examples to show.

var oMyNewGB = new DzGroupBox();oMyNewGB.paletteBackgroundColor.setRgb( 0,0,0 ); // does nothingoMyNewGB.paletteBackgroundPixmap = new Pixmap( pathToImage ); // does nothingoMyNewGB.palette.window = new Color( 0,0,0 ); // does nothingoMyNewGB.palette.active.window = new Color( 0,0,0 ); // also does nothingoMyNewGB.palette.active.window.setRgb( 0,0,0 ); // alas also does nothingoMyNewGB.palette.window.value // returns the number 95oMyNewGB.palette.window.value = 100; // does nothing - value is still 95 

So my question is - what is the magic sauce for actually changing the colour of interface widgets in script?

Post edited by HowieFarkes on

Comments

  • Cayman StudiosCayman Studios Posts: 1,134

    Howie, try this:

    var wSet = new DzDialog;var sMsgBoxTitle = "Test Dialog Box";var wOKButton = new DzPushButton( wSet );wSet.caption = sMsgBoxTitle;wOKButton.text = "OK";wOKButton.setGeometry( 280,165,80,25 );wOKButton.autoDefault = true;wSet.setFixedSize(380,240);wSet.paletteBackgroundColor = Color(0,0,0);function OKSet() {	wSet.close();}connect( wOKButton, "clicked()", OKSet );wSet.exec();

     

  • HowieFarkesHowieFarkes Posts: 585

    Yeah, paletteBackgroundColor() seems to work on (and only on) DzDialog. I can't seem to change the color of any other widget.

  • Cayman StudiosCayman Studios Posts: 1,134

    Well, I suppose one workaround might be to use a Pixmap on the Dialog which is coloured in precisely the place you want the group box.

  • andya_b341b7c5f5andya_b341b7c5f5 Posts: 694
    edited August 2018

    I have hit the same problem, that for example the background and foreground colors of a DzLabel can't be manipulated via a palette, and wonder if this is expected behaviour, or rather lack of it.

    I have managed to use a pixmap as the label and text via

    var oPMap = new Pixmap();oPMap.fromImage(Image("C:/Users/Bob/Pictures/pixmap.xpm"));wLabel01.pixmap = oPMap; wDlg.addWidget(wLabel01, DzWidget.AlignCenter);

    (But the  DzWidget.AlignCenter has absolutely no effect here...sad).  This could mean creating a load of little pixmaps, which will be tedious to say the least.

    Sorry, tried 5 times to get code snippet to format properly, but it refuses so I give up.

    Post edited by andya_b341b7c5f5 on
  • The addWidget method for DzBasicDialog has three parameters, not two.  So

    wDlg.addWidget(wLabel01, 0, DzWidget.AlignCenter);

    should do it.

  • The addWidget method for DzBasicDialog has three parameters, not two.  So

    wDlg.addWidget(wLabel01, 0, DzWidget.AlignCenter);

    should do it.

    Ah yes, excellent point!  I'll try that at the next opportunity.

    And somehow my code snippet seems to be displaying correctly now.  If somebody fixed that for me, thanks!

Sign In or Register to comment.