Advertisement
gr4ph0s

C4D subdialog example

Dec 14th, 2017
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.46 KB | None | 0 0
  1. import c4d
  2.  
  3. class Sub(c4d.gui.SubDialog):
  4.     def CreateLayout(self):
  5.         self.AddStaticText(1001, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, 0, 0, "SubDialog", c4d.BORDER_THIN_IN)
  6.         return True
  7.    
  8. class AutreSub(c4d.gui.SubDialog):
  9.     def CreateLayout(self):
  10.         self.AddStaticText(1001, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, 0, 0, "Autre Sub", c4d.BORDER_THIN_IN)
  11.         return True
  12.  
  13. class test(c4d.gui.GeDialog):
  14.     sub = Sub()
  15.    
  16.     def CreateLayout(self):
  17.         self.AddButton(1002, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT)
  18.         self.AddSubDialog(1001, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, 100, 100)
  19.         self.AttachSubDialog(self.sub, 1001)
  20.        
  21.         return True
  22.    
  23.     def Command(self, id, msg):
  24.         if id == 1002:
  25.             self.sub = AutreSub()
  26.             self.AttachSubDialog(self.sub, 1001)
  27.             self.LayoutChanged(1001)
  28.            
  29.         return True
  30.  
  31. def main():
  32.     dlg = test()
  33.     dlg.Open(c4d.DLG_TYPE_MODAL_RESIZEABLE,  defaultw=400, defaulth=400)
  34.  
  35. if __name__=='__main__':
  36.     main()
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52. import c4d
  53.  
  54. class Sub(c4d.gui.SubDialog):
  55.     def CreateLayout(self):
  56.         self.AddStaticText(1001, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, 0, 0, "SubDialog", c4d.BORDER_THIN_IN)
  57.         self.AddButton(1002, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT)
  58.  
  59.         return True
  60.    
  61.     def Message(self, msg, result):
  62.       if msg.GetId() == 1002:
  63.           print 'Sub'
  64.       return c4d.gui.SubDialog.Message(self, msg, result)    
  65.    
  66.     def Command(self, id, msg):
  67.         if id == 1002:
  68.             bc = c4d.BaseContainer()
  69.             bc.SetId(2000)
  70.             self.SendParentMessage(bc)
  71.            
  72.         return True
  73.    
  74.  
  75. class test(c4d.gui.GeDialog):
  76.     sub = Sub()
  77.    
  78.     def CreateLayout(self):
  79.         self.AddSubDialog(1001, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, 100, 100)
  80.         self.AttachSubDialog(self.sub, 1001)
  81.        
  82.         return True
  83.    
  84.     def Command(self, id, msg):
  85.         print id, msg          
  86.         return True
  87.    
  88.    
  89.     def Message(self, msg, result):
  90.       if msg.GetId() == 2000:
  91.           print 'MainDLG'
  92.           bc = c4d.BaseContainer()
  93.           bc.SetId(1002)
  94.           self.SendMessage(self.sub.GetId(), bc)
  95.       return c4d.gui.GeDialog.Message(self, msg, result)
  96.  
  97. def main():
  98.     dlg = test()
  99.     dlg.Open(c4d.DLG_TYPE_MODAL_RESIZEABLE,  defaultw=400, defaulth=400)
  100.  
  101. if __name__=='__main__':
  102.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement