'Checks for the existence `attr` on a given `panel` and
performs `action` if found'

def _set_visibility(self, action, *args):

    def _set_visibility(obj, attrs):
        for attr in attrs:
            if hasattr(obj, attr):
                instance = getattr(obj, attr)
                getattr(instance, action)()
                instance.Layout()
    for panel in [self, self.head_panel, self.foot_panel, self.config_panel]:
        _set_visibility(panel, args)
