On 26/12/2016 at 19:49, xxxxxxxx wrote:
Hello there,
How can I send the variable "Value" from the main dialog to the sub dialog, check script and screenshot below :
import c4d
from c4d import gui, bitmaps
NO = 21549
YES = 21547
CHECK_ICON = 21548
class subDialog(gui.GeDialog) :
def CreateLayout(self) :
self.SetTitle("Sub Dialog")
self.GroupBegin(id=0, flags=c4d.BFH_SCALEFIT, cols=2)
self.GroupBorderSpace(0, 0, 10, 0)
bc = c4d.BaseContainer()
fn = bitmaps.InitResourceBitmap(c4d.Tprotection)
self.myBitButton=self.AddCustomGui(CHECK_ICON, c4d.CUSTOMGUI_BITMAPBUTTON, "Bitmap Button", c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, 50, 50, bc)
self.myBitButton.SetImage(fn, False)
self.GroupBegin(id=0, flags=c4d.BFH_CENTER, cols=1)
self.AddStaticText(7, c4d.BFH_LEFT, 0, 0, "The value " + **str(Value)** \+ " is higher than the recommended value", c4d.BORDER_NONE) **# Send the variable "Value" here**
self.AddStaticText(7, c4d.BFH_LEFT, 0, 0, "Press YES to continue or NO to cancel", c4d.BORDER_NONE)
self.GroupEnd()
self.GroupEnd()
self.AddSeparatorH(0, c4d.BFH_SCALEFIT)
self.GroupBegin(id=0, flags=c4d.BFH_CENTER, cols=2)
self.AddButton(YES, c4d.BFH_CENTER, 30, 15, name="YES")
self.AddButton(NO, c4d.BFH_CENTER, 30, 15, name="NO")
self.GroupEnd()
return True
def Command(self, id, msg) :
if (id == YES) :
self.Response = True
self.Close()
if (id == NO) :
self.Response = False
self.Close()
return True
class mainDialog(c4d.gui.GeDialog) :
def CreateLayout(self) :
self.SetTitle("Main Dialog")
self.AddButton(11001, c4d.BFH_SCALEFIT, 0, 20, "Open Sub Dialog")
return True
def Command(self, id, msg) :
if id == 11001:
**Value = 1800 # How to send this variable to the sub dialog**
if Value > 1500 :
self.subDialog = subDialog()
self.subDialog.Open(dlgtype=c4d.DLG_TYPE_MODAL, defaultw=300, defaulth=0)
if self.subDialog.Response == True :
print self.subDialog.Response
else :
print self.subDialog.Response
return True
def main() :
global mainDialog
mainDialog = mainDialog()
mainDialog.Open(c4d.DLG_TYPE_MODAL, xpos=700, ypos= 200, defaultw=516, defaulth=10)
return True
if __name__=='__main__':
main()
Thanks.