Arrange UI Elements



  • 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
    


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

    I suggest you to read https://developers.maxon.net/docs/Cinema4DCPPSDK/html/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()
    


  • 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.


Log in to reply