Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Arrange UI Elements

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 400 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      On 19/07/2017 at 08:15, xxxxxxxx wrote:

      Hi,

      I'm quite new to python for c4d, so it might be newbie question.

      Does anyone know how to organize elements so that they are arragend next to each other instead of top/down?

      this is my current class

      class MainMenu(gui.GeDialog) :
          def CreateLayout(self) :
              
              
              template_fn = next(os.walk(path))[2]
              template_filecnt = len(template_fn)
              #print template_fn
              #print template_filecnt
              
              bc = c4d.BaseContainer()    #Create a new container to store the button image                    
              buttid = 1000               #start id for 1000
              i=0                         #set iterator
              
              for list in template_fn: 
                  
                  #create buttons                              
                  template_path = os.path.normpath(os.path.join(dir,'res/templates/',template_fn[i]))   #The path to the image  
                  bc.SetFilename(buttid, template_path)                                  #Add this location info to the conatiner
                  self.myBitButton=self.AddCustomGui(buttid, c4d.CUSTOMGUI_BITMAPBUTTON, "Bitmap Button", c4d.BFH_CENTER, 30, 30, bc)
                  self.myBitButton.SetImage(template_path, False)                                  #Add the image to the button 
                                      
                  #button id counter, gives every button unique id, i = loop counter for iteration through list
                  buttid+=1
                  i+=1
              
              
                  
              return True
          
          def Command(self, id, msg=None) :
              print id
              return True
      
      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 19/07/2017 at 08:56, xxxxxxxx wrote:

        I suggest you to read https://developers.maxon.net/docs/cpp/2023_2/page_manual_gedialog.html you gonna learn alot about dialog inside c4d.

        According your ask take basicly you have to make a group to arrange them.

        So it's looks like this

        import c4d
          
        class MainMenu(c4d.gui.GeDialog) :
            def CreateLayout(self) :
                count = 10
                id_group = 10001
                base_id_text = 10002
                
                #important to set columns number
                if self.GroupBegin(id_group, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, cols=count) :
                
                    #Add content to our group
                    for i in xrange(count) :
                        self.AddStaticText(base_id_text + i, c4d.BFH_SCALEFIT, name="text_{}".format(str(i)))
          
                self.GroupEnd()
                
                return True
                
          
        def main() :
            win = MainMenu()
            win.Open(c4d.DLG_TYPE_MODAL_RESIZEABLE)
          
        if __name__=='__main__':
            main()
        
        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 20/07/2017 at 00:28, xxxxxxxx wrote:

          Thanks, it works like a charm!

          and thanks for the cpp manual link it gives lots more info then the python one.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post