How to create splitted dialog window



  • Hello guys!
    I have to make command plugin dialog window like on this example. How to add two groups with possibility to change size of two separated zones by dragging divider. Thank you!

    ca2f21b4-eb12-4e1d-a4fc-4ca228fd994b-image.png



  • https://developers.maxon.net/docs/Cinema4DPythonSDK/html/modules/c4d.gui/GeDialog/index.html#GeDialog.GroupWeightsLoad

    I will come back with a proper reply when the SDK Team is back from holiday.
    Have a happy new year!
    Cheers,
    Maxime. :)



  • @m_adam said in How to create splitted dialog window:

    happy new year!

    Thank you!



  • Hi @mikeudin sorry to not come back earlier I forget about it.

    Since I see it's still open I'm wondering if you have more questions about it.
    But in any case, here it's how it works.
    So you have to make a group with the flag c4d.BFV_GRIDGROUP_ALLOW_WEIGHTS then each element (gadget) of this group will have a dynamic size and can be dragged.
    Then you must define some default parameters (like how many columns the group has).
    This is done through a BaseContainer.
    Then GeDialog.GroupWeightsLoad will apply the data from the BaseContainer.

    Then to retrieve the new values defined when the user resizes something you can use GeDialog.GroupWeightsSave from the Message method by reacting to BFM_WEIGHTS_CHANGED.

    Find a complete GeDialog example bellow

    class MyDialog(c4d.gui.GeDialog):
    
        GRP_SUB = 10000
    
        def __init__(self):
            # A BaseContainer that will store the information about weight information of the group.
            # This is stored in a class member variable, this way if the dialog is closed and re-open 
            # weight information will not be lost and restored as previously
            self.groupWeights = c4d.BaseContainer()
            
        def CreateLayout(self):
            """
            This method is called automatically when Cinema 4D Create the Layout (display) of the Dialog.
            """
    
            if self.GroupBegin(self.GRP_SUB, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, 2, 0, "", c4d.BFV_GRIDGROUP_ALLOW_WEIGHTS):
        
                self.AddStaticText(1000, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, 0, 0, "1", c4d.BORDER_THIN_IN)
                self.AddStaticText(1001, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, 0, 0, "2", c4d.BORDER_THIN_IN)
        
                self.AddStaticText(1002, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, 0, 0, "3", c4d.BORDER_THIN_IN)
                self.AddStaticText(1003, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, 0, 0, "4", c4d.BORDER_THIN_IN)
        
                self.AddStaticText(1004, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, 0, 0, "5", c4d.BORDER_THIN_IN)
                self.AddStaticText(1005, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, 0, 0, "6", c4d.BORDER_THIN_IN)
        
                self.AddEditNumberArrows(1006, c4d.BFH_SCALEFIT)
            self.GroupEnd()
            
        def InitValues(self):
            """
            This method is called automatically only the first time the instance dialog is opened after the GUI is initialized (CreateLayout).
            """
            
            # Sets the columns, count has to be equal to the given layout (defined in CreateLayout, GroupBegin)
            # Sum of all collums weight should be equal to 100.0
            self.groupWeights.SetInt32(c4d.GROUPWEIGHTS_PERCENT_W_CNT, 2)     
            self.groupWeights.SetFloat(c4d.GROUPWEIGHTS_PERCENT_W_VAL + 0, 25.0)  # weight for col 1
            self.groupWeights.SetFloat(c4d.GROUPWEIGHTS_PERCENT_W_VAL + 1, 75.0)  # weight for col 2
    
            # Sets the rows, count has to be equal to the given layout (defined in CreateLayout, GroupBegin)
            # Sum of all rows weight should be equal to 100.0
            self.groupWeights.SetInt32(c4d.GROUPWEIGHTS_PERCENT_H_CNT, 4)
            self.groupWeights.SetFloat(c4d.GROUPWEIGHTS_PERCENT_H_VAL + 0, 10.0)  # weight for row 1
            self.groupWeights.SetFloat(c4d.GROUPWEIGHTS_PERCENT_H_VAL + 1, 30.0)  # weight for row 2
            self.groupWeights.SetFloat(c4d.GROUPWEIGHTS_PERCENT_H_VAL + 2, 60.0)  # weight for row 3
            self.groupWeights.SetFloat(c4d.GROUPWEIGHTS_PERCENT_H_VAL + 3, 0.0)   # weight for row 4
    
            # Defines the initial weight value of the group from the stored BaseContainer
            self.GroupWeightsLoad(self.GRP_SUB, self.groupWeights)
            
            return True
        
        def Message(self, msg, result):
            """
            This method is called automatically when the GeDialog receives a Message.
    
            :param msg: The message container.
            :param result: A container to place results in.
            """
            # Checks if the receveid message is about a weight change
            if msg.GetId() == c4d.BFM_WEIGHTS_CHANGED:
    
                # Retrieves the dragged host group
                if msg.GetInt32(c4d.BFM_WEIGHTS_CHANGED) == self.GRP_SUB:
    
                    # Stores the new weights values
                    self.groupWeights = self.GroupWeightsSave(self.GRP_SUB)
                    
            return c4d.gui.GeDialog.Message(self, msg, result)
    

    Cheers,
    Maxime.



  • @m_adam said in How to create splitted dialog window:

    But in any case, here it's how it works.

    Thank you very much, Maxime! Great example!