Hi,
I have this old script that works well with DLG_TYPE_MODAL_RESIZEABLE
but with this mode I am locked into the UI until I click exit. I wanted a floating dialog with what DLG_TYPE_ASYNC
provides. The problem is the button does not work.
When you click the button, a string is printed in the console.
Is there a way around this?
Thank you for looking at my problem.
You can see the code below:
import c4d
from c4d import gui
class Colorizer(gui.GeDialog):
def CreateLayout(self):
self.SetTitle('Colorizer')
# Prepare a red bitmap for the button.
w = 50
h = 50
bmpRed = c4d.bitmaps.BaseBitmap()
bmpRed.Init(w, h)
for y in xrange(w):
for x in xrange(h):
bmpRed.SetPixel(x, y, 255, 0, 0)
# BitmapButton configuration
bcBitmapButton = c4d.BaseContainer()
bcBitmapButton[c4d.BITMAPBUTTON_BUTTON] = True
# Add a BitmapButton to the dialog.
# _bitmapButton is a member variable of the dialog class
buttonId = 2000
_bitmapButton = self.AddCustomGui(buttonId, c4d.CUSTOMGUI_BITMAPBUTTON, "", c4d.BFH_CENTER|c4d.BFV_CENTER, w, h, bcBitmapButton)
if _bitmapButton is None:
print "Handle this error!"
# Assign the image to the button.
# Note: Let it create an internal copy as the created bitmap will be free'd, when scope is left.
_bitmapButton.SetImage(bmpRed, True)
def Command(self, id, msg):
if id==2000: # corresponds to the button ID used in the code snippet in the first answer in this thread
print "My Bitmap Button"
return True
def main():
dialog = Colorizer()
dialog.Open(c4d.DLG_TYPE_ASYNC, defaultw=300,defaulth=100)
#dialog.Open(c4d.DLG_TYPE_MODAL_RESIZEABLE, defaultw=300,defaulth=100) # Works but I can't click on the interface. Basically, I'm locked until I click exit. '
if __name__=='__main__':
main()