PyMEL: formLayout edit failure

I’m currently writing a UI-class for a kind of material swatch object (it will make things easier for me in the long run), and I have this snippet of code that just doesn’t appear to… well, work!

class Swatch():

    def __init__(self, cmd, labCmd, name, parentLayout, height=72, width=64):
        """ Description: Creates a swatch UI object 
        @params:
            cmd (Object) - Callback object with the swatch command
            labCmd (Object) - Callback object with the label command
            name (String) - Material/Shader name. Used for the swatch image and label.
            parentLayout (String) - Parent layout to this object
            height (Int) - Height of this object
            width (Int) - Width of this object
        """

        # Object properties
        self.cmd = cmd
        self.labCmd = labCmd
        self.name = name
        self.parent = parentLayout
        self.height = height
        self.width = width

        self.labelHeight = self.height / 6

        # Create layout and UI controls
        self.layout = pm.formLayout(
            backgroundColor=[0.0, 0.5, 0.5],
            parent=self.parent,
        )
        self.icon = pm.swatchDisplayPort(
            annotation=self.name,
            parent=self.layout, # Testing - unnecessary flag
            pressCommand=self.cmd,
            renderSize=self.width,
            shadingNode=self.name,
            widthHeight=[ self.width, self.height ]
        )
        self.label = pm.iconTextButton(
            annotation=self.name,
            backgroundColor=[0.7, 0.7, 0.7],
            command=self.labCmd,
            height=self.labelHeight,
            label=self.name,
            parent=self.layout, # Testing - unnecessary flag
            style="textOnly",
            width=self.width,
        )

        pm.formLayout(
            self.layout, edit=True,
            attachForm=[
                (self.icon, "left", 0),
                (self.icon, "right", 0),
                (self.label, "left", 10), # Experiment to see if this edit actually takes place at all (it doesn't!)
            ],
            attachControl=[
                (self.icon, "bottom", 0, self.label),
                (self.label, "top", 0, self.icon),
            ]
        )

        # Remaining methods has been omitted

The odd thing is that if I remove the block containing the formLayout edit, I get EXACTLY the same results as when I have it there - In other words: it doesn’t do anything. Instead I get this scrambled UI where whatever comes first (icon or label) appears first in the formLayout.
Now I’ve worked with the formLayout plenty of times before and never encountered this particular problem and was kinda hoping to see if someone here might have came across the same problem. I’m not exactly sure where to start with this problem!

NVM - this is slightly embarrassing xD
The main cause of my confusion came from the fact that the labels were rendered -UNDER- the other Swatch -objects and some even outside the container I’ve placed them in.
By changing the attachForm/attachControl flag and adding a negative offset to the label I saw that this was strictly a visual problem posing as a code problem. How irritating!


class Swatch():

    def __init__(self, cmd, labCmd, name, parentLayout, height=72, width=64):
        """ Description: Creates a swatch UI object 
        @params:
            cmd (Object) - Callback object with the swatch command
            labCmd (Object) - Callback object with the label command
            name (String) - Material/Shader name. Used for the swatch image and label.
            parentLayout (String) - Parent layout to this object
            height (Int) - Height of this object
            width (Int) - Width of this object
        """

        # Object properties
        self.cmd = cmd
        self.labCmd = labCmd
        self.name = name
        self.parent = parentLayout
        self.height = height
        self.width = width

        self.labelHeight = self.height / 6

        # Create layout and UI controls
        self.layout = pm.formLayout(
            backgroundColor=[0.0, 0.5, 0.5],
            parent=self.parent,
        )
        self.icon = pm.swatchDisplayPort(
            annotation=self.name,
            parent=self.layout, # Testing - unnecessary flag
            pressCommand=self.cmd,
            renderSize=self.width,
            shadingNode=self.name,
            widthHeight=[ self.width, self.height ]
        )
        self.label = pm.iconTextButton(
            annotation=self.name,
            backgroundColor=[0.7, 0.7, 0.7],
            command=self.labCmd,
            height=self.labelHeight,
            label=self.name,
            parent=self.layout, # Testing - unnecessary flag
            style="textOnly",
            width=self.width,
        )

        pm.formLayout(
            self.layout, edit=True,
            attachForm=[
                (self.icon, "left", 0),
                (self.label, "left", 0),
            ],
            attachControl=[
                (self.label, "top", -20, self.icon), # THIS CHANGES EVERYTHING!!!
            ]
        )

        # Remaining methods has been omitted