Open window on button click

Hi, i simply want to open a new window when the user clicks on a button. I have this code (not working)

...
Rect x = new Rect(250, 0, 150, 250);
string ctype = "aaa";
if (GUILayout.Button(ctype))
{
   x = GUI.Window(0, x, ConstraintPicker, "Pick a Constraint");
}
...

public void ConstraintPicker(int id)
    {
        GUILayout.BeginArea(new Rect(0, 15, 150, 250));
        scroller = GUILayout.BeginScrollView(scroller);
        foreach( string item in constraints )
        {
            if (GUILayout.Button(item.ToString(), GUI.skin.GetStyle("Button")))
            {
                ctype = item;
            }
        }
        GUILayout.EndScrollView();
        GUILayout.EndArea();
    }

window gets displayed if i remove the if construct and leave the body

class variable

bool showWindow = false;

In OnGUI

if (GUILayout.Button(ctype))
{
    showWindow = true;
}    

if (showWindow)
{
    x = GUI.Window(0, x, ConstraintPicker, "Pick a Constraint");
}

And whenever you want to stop showing the window again obviously just change showWindow back to false.