module example1\#auto -title "An example GUI" -script {
    
    # 1st-line of input
    
    line ktype -name "K-point input" {        
        keyword kpoints K_POINTS        
        var kpoint_type {
            -label     "K-Point input" 
            -textvalue { "Automatic generation" "Gamma point only" }
            -value     { automatic gamma }            
            -widget    radiobox
        }
    }


    # 2nd-line of input
    
    line kmesh -name "K-point mesh" {
	packwidgets left
        var nk1  -label "nk1:"  -widget entry  -validate posint  -default 1
        var nk2  -label "nk2:"  -widget entry  -validate posint  -default 1
        var nk3  -label "nk3:"  -widget entry  -validate posint  -default 1
    }


    # 3rd-line of input
    
    line kshift -name "K-point mesh shift" {
	packwidgets left
        var s1 -label "s1:"  -widget entry  -validate posint  -default 1
        var s2 -label "s2:"  -widget entry  -validate posint  -default 1
        var s3 -label "s3:"  -widget entry  -validate posint  -default 1
    }


    #
    # Event-driven mechanism:
    # -----------------------
    # disable/enable the "K-point mesh" and "K-point mesh shift" widgets
    # depending on the value of kpoint_type variable
    #

    tracevar kpoint_type w {
        set value [vartextvalue kpoint_type]    
        if { $value == "Automatic generation" } {
            set status enable
        } else {
            set status disable
        }
        
        groupwidget kmesh $status
        groupwidget kshift $status
    }
}
