Hi,
Is there a way I can gray out a button that doesn't need a specific condition?
You can see an illustration of the problem here:
https://www.dropbox.com/s/rfw2nw8o298r0ej/c4d162_python_gray_out_custom_gui_button.jpg?dl=0
I used the SetToggleState(set)
, BITMAPBUTTON_ICONID1
and BITMAPBUTTON_ICONID2
but I am having a problem on implementing it.
Here is the code so far:
import c4d
from c4d import bitmaps, documents, gui, plugins, threading, utils
PLUGIN_ID = 1011328
class MyDialog(gui.GeDialog):
def CreateLayout(self):
self.SetTitle('Colorizer')
self.doc = c4d.documents.GetActiveDocument()
# Prepare a red bitmap for the button.
w = 50
h = 50
# BitmapButton configuration
bcBitmapButton = c4d.BaseContainer()
bcBitmapButton[c4d.BITMAPBUTTON_BUTTON] = True
bcBitmapButton[c4d.BITMAPBUTTON_ICONID1] = c4d.Ocube
bcBitmapButton[c4d.BITMAPBUTTON_ICONID2] = c4d.Oplane # should be the greyed out Ocube
buttonId = 2000
_bitmapButton = self.AddCustomGui(buttonId, c4d.CUSTOMGUI_BITMAPBUTTON, "", c4d.BFH_CENTER|c4d.BFV_CENTER, w, h, bcBitmapButton)
icon = c4d.bitmaps.InitResourceBitmap(c4d.Ocube)
_bitmapButton.SetImage(icon, True)
if len(doc.GetActiveObjects())>0:
_bitmapButton.SetToggleState(0)
else:
_bitmapButton.SetToggleState(1)
return True
def Command(self, id, msg):
if id==2000 :
print "Create Cube"
return True
class MyMenuPlugin(plugins.CommandData):
dialog = None
def Execute(self, doc):
# create the dialog
if self.dialog is None:
self.dialog = MyDialog()
return self.dialog.Open(dlgtype=c4d.DLG_TYPE_ASYNC, pluginid=PLUGIN_ID, defaultw=200, defaulth=150, xpos=-1, ypos=-1)
def RestoreLayout(self, sec_ref):
# manage the dialog
if self.dialog is None:
self.dialog = MyDialog()
return self.dialog.Restore(pluginid=PLUGIN_ID, secret=sec_ref)
if __name__ == "__main__":
okyn = plugins.RegisterCommandPlugin(PLUGIN_ID, "Cubey",0, None, "Cubey initialized", MyMenuPlugin())
if (okyn):
print "Cubey initialized"
Thank you for looking at my problem