Radio button groups in two columns



  • Hi, I have tried to design dialog box layout with two columns, each with RadioGroup inside. So I created nested level 2 groups - and it worked with static text, but when I added RadioGroups to level 2 groups, it never worked. Any idea what is wrong here?

    self.GroupBegin(GROUP_ID0, c4d.BFH_SCALEFIT, 2,0)
    self.GroupBorderSpace(10,10,10,10)
    
    self.GroupBegin(GROUP_ID1, c4d.BFH_SCALEFIT, 1,0)
    #self.AddStaticText(id=1001,flags=c4d.BFH_LEFT,initw=100, name="Left column")
    self.AddRadioGroup(RADIO_GROUP1, c4d.BFH_LEFT, 1, 0)
    self.AddChild(RADIO_GROUP1, RADIO1_A, 'Option A1')
    self.AddChild(RADIO_GROUP1, RADIO1_B, 'Option B1')
    self.SetBool(RADIO1_A, True)  # Set first radio button on.
    self.GroupEnd()
    self.GroupEnd()
    
    
    self.GroupBegin(GROUP_ID2, c4d.BFH_SCALEFIT, 1, 0)
    #self.AddStaticText(id=1002,flags=c4d.BFH_LEFT,initw=100, name="Right column")
    self.AddRadioGroup(RADIO_GROUP2, c4d.BFH_LEFT, 1, 0)
    self.AddChild(RADIO_GROUP2, RADIO2_A, 'Option A1')
    self.AddChild(RADIO_GROUP2, RADIO2_B, 'Option B2')
    self.SetBool(RADIO2_A, True)  # Set first radio button on.
    self.GroupEnd()
    self.GroupEnd()
    
    self.GroupEnd()
    

    Thanks,

    Stan



  • Hi, @stanDM first of all welcome in the plugincafe community.

    No worry since it's your first post but please read the next topic in order to set up your next topic correctly.

    Finally, regarding your issue, AddRadioGroup will not create a group, so you don't need to close it, so when you are doing

    self.GroupBegin(GROUP_ID0, c4d.BFH_SCALEFIT, 2,0)
    self.GroupBorderSpace(10,10,10,10)
    
    self.GroupBegin(GROUP_ID1, c4d.BFH_SCALEFIT, 1,0)
     ....
    self.GroupEnd()
    self.GroupEnd()
    

    So you are closing the GROUP_ID1 and the GROUP_ID0.

    I agree since there is the word Group in AddRadioGroup this is rather confusing, I will add a note in the documentation.

    Cheers,
    Maxime.



  • Hi Maxime,

    thanks a lot for help! I have deleted Group.End for RadioGroup, but I still cannot achieve the desired layout - for one static text field it worked, but not for RadioGroups or RadioGroups nested in Groups. I have tried to change different params but could not make it work.

    Enclosed is the image of what I try to achieve. Any idea how to do it is appreciated!

    pythonDialog.jpg

    Thanks, Stan

    P.S. next time I will make sure my topic is tagged properly :)



  • sorry to hijack this, but regarding adding tags to posts:
    on my macbook pro 13" the taglist is higher than the screen, and you cant scroll it.
    it is not possible to select "python" for example
    (just for your info)



  • Hi @stanDM, I apologize for the very late reply I forget your topic.

    Regarding your issue, here the code that produces your expected result.

    import c4d
    
    
    class ExampleDialog(c4d.gui.GeDialog):
    
        def CreateLayout(self):
            # Create the main group of 2 collumns
            if self.GroupBegin(1000, c4d.BFH_FIT | c4d.BFH_LEFT, 2, 1):
                self.GroupBorderSpace(10,10,10,10)
                
                # Create the first Group collum
                if self.GroupBegin(1010, c4d.BFH_SCALEFIT, 1, 0, title="Left column"):
                    self.GroupBorder(c4d.BORDER_GROUP_OUT)
                    #self.AddStaticText(id=1011,flags=c4d.BFH_LEFT, name="Left column")
                    
                    self.AddRadioGroup(1012, c4d.BFH_LEFT, 1, 0)
                    self.AddChild(1012, 0, 'Option A1')
                    self.AddChild(1012, 1, 'Option B1')
                    self.SetInt32(1012, 0) # Set first radio button on.
                self.GroupEnd() # Close the first collumn group
            
                # Create the second Group collum
                if self.GroupBegin(1020, c4d.BFH_FIT | c4d.BFH_LEFT, 1, 0, title="Right column"):
                    self.GroupBorder(c4d.BORDER_GROUP_OUT)
                    #self.AddStaticText(id=1021,flags=c4d.BFH_LEFT, name="Right column")
                    
                    self.AddRadioGroup(1022, c4d.BFH_LEFT, 1, 0)
                    self.AddChild(1022, 0, 'Option A1')
                    self.AddChild(1022, 1, 'Option B2')
                    self.SetInt32(1022, 1) # Set second radio button on.
                self.GroupEnd() # Close the second collumn group
                
            self.GroupEnd()
    
    
            return True
    
    
    
    def main():
        global dlg
        dlg = ExampleDialog()
    
        # Opens the GeDialog
        dlg.Open(c4d.DLG_TYPE_ASYNC, defaultw=300, defaulth=50)
    
    if __name__ == "__main__":
        main()
    

    As a tip, I would recommend using if statement so you clearly see the scope of a Group, nothing official, but it's a guideline I try to follow as it helps a lot to avoid issues like yours with nested groups

    Cheers,
    Maxime.



  • Hi Maxime,

    it now works great, thank you very much for your support!

    Cheers,
    Stan