PDA

View Full Version : Change the color of button


Eugene
06-22-2016, 11:07 AM
I've created a few panels with different buttons. One of them shown below. I would like to change the button color when selected for specific panel to another color. May I know how could I do it?

For example, I would like PrimeOffButton.set(1) to be red instead of default color.

PrimeOffButton = viz.addButtonLabel('Off')
PrimeOffButton.set(1)
PrimeKeepAliveButton = viz.addButtonLabel('Keep-Alive')
PrimeKeepAliveButton.set(0)
PrimeOperationalButton = viz.addButtonLabel('Operational')
PrimeOperationalButton.set(0)
subpanel2.addItem(viz.addText('SSRMS Prime String'))
subpanel2.addItem(PrimeOffButton)
subpanel2.addItem(PrimeKeepAliveButton)
subpanel2.addItem(PrimeOperationalButton)

Thanks.

Jeff
06-23-2016, 05:25 AM
You can set the GUI theme globally, for an individual GUI element (http://docs.worldviz.com/vizard/#commands/node3d/GUI/setTheme.htm), or for a GUI container that contains the button. The example script in this thread (http://forum.worldviz.com/showthread.php?t=5056) shows how changing various theme properties affects a menu and info panel:

import viz
import vizinfo
viz.go()

theme = viz.getTheme()
theme.highBackColor = (1,0,0,1)

button = viz.addButtonLabel('Off',pos=[0.2,0.95,1])
button.set(1)
button.setTheme(theme)

infoPanel = vizinfo.InfoPanel('Panel')
infoPanel.getPanel().setTheme(theme)
panelbutton = infoPanel.addItem(viz.addButtonLabel('Off'))
panelbutton.set(1)