You only have to call the rowLayout command (http://help.autodesk.com/cloudhelp/2017/ENU/Maya-Tech-Docs/Commands/rowLayout.html)
with -e (for edit) and -visbile. Finally the name of the rowLayout:
rowLayout -e -visible false "NAME";
To read the value you have to specify -q (for query) instead of -e
int $visiblity = `rowLayout -q -visible "NAME"`;
global proc OnMakeRowInvisible(string $rl)
{
rowLayout -e -visible false $rl;
}
global proc ShowWindow()
{
string $sWindow = `window -title "TestWindow"
-widthHeight 300 112`;
columnLayout;
rowLayout -numberOfColumns 2 MyRowLayout;
text -label "TestA";
text -label "TestB";
setParent ..;
string $cmd = "OnMakeRowInvisible(\"MyRowLayout\")";
print $cmd;
button -label "Make Invisible" -width 150 -command $cmd;
button -label "Cancel" -width 150 -command ("deleteUI -window " + $sWindow);
setParent ..;
showWindow $sWindow;
}
ShowWindow()
Hope it helps you.