I tried using the subdialog as the github example shows. If I just want to do one subdialog change the github example that @mogh posted works just find. However when I add another button so I can switch between the subdialogs the Dialog does not update.
The code I used is a bit modified from the github but more or less the same:
import c4d
from c4d import gui
ID_SUBDIALOG = 10000
ID_Dialog1_BUTTON = 10001
ID_Dialog2_BUTTON = 10002
class Dialog1(c4d.gui.SubDialog):
def CreateLayout(self):
self.AddStaticText(1, c4d.BFH_SCALEFIT, 0, 0, "Dialog 1")
return True
class Dialog2(c4d.gui.SubDialog):
def CreateLayout(self):
self.AddStaticText(1, c4d.BFH_SCALEFIT, 0, 0, "Dialog 2")
return True
class MainDialog(c4d.gui.GeDialog):
subDialog = Dialog1()
def CreateLayout(self):
self.GroupBegin(0, c4d.BFH_SCALEFIT, 2)
self.AddButton(ID_Dialog1_BUTTON, c4d.BFH_SCALEFIT, name="Dialog1")
self.AddButton(ID_Dialog2_BUTTON, c4d.BFH_SCALEFIT, name="Dialog2")
self.GroupEnd()
self.AddSubDialog(ID_SUBDIALOG, c4d.BFH_SCALEFIT, 100, 100)
self.AttachSubDialog(self.subDialog, ID_SUBDIALOG)
return True
def Command(self, mid, msg):
if mid == ID_Dialog1_BUTTON:
self.subDialog = Dialog1()
self.AttachSubDialog(self.subDialog, ID_SUBDIALOG)
print(self.LayoutChanged(ID_SUBDIALOG))
if mid == ID_Dialog2_BUTTON:
self.subDialog = Dialog2()
self.AttachSubDialog(self.subDialog, ID_SUBDIALOG)
print(self.LayoutChanged(ID_SUBDIALOG))
return True
if __name__=='__main__':
dlg = MainDialog()
dlg.Open(c4d.DLG_TYPE_ASYNC, defaultw=900, xpos=-2, ypos=-2)
When I click the buttons the first button click from either button the LayoutChanged returns True but on the second button click from either button returns False.
What am I doing wrong?