
set LFrame $DLabels.lframe

UploadLabels

destroy $DLabels
toplevel $DLabels
wm title $DLabels "GOBLIN Arc Attributes"
wm resizable $DLabels 0 0
DownloadArcLabels $currentArc

frame $LFrame
     
    label $LFrame.indexText -text "Arc Index" -anchor w
    grid $LFrame.indexText -in $LFrame \
        -row 0 -column 0 -rowspan 1 -columnspan 1 -sticky news -padx 1m -pady 2m
    label $LFrame.index -textvariable ThisArc -anchor w
    grid $LFrame.index -in $LFrame \
        -row 0 -column 1 -rowspan 1 -columnspan 1 -sticky news -padx 1m -pady 2m

    label $LFrame.upperText -text "Upper Bound" -anchor w
    grid $LFrame.upperText -in $LFrame \
        -row 1 -column 0 -rowspan 1 -columnspan 1 -sticky news -padx 1m
    entry $LFrame.upper -textvariable ThisUpper -bg white -width 10
    grid $LFrame.upper -in $LFrame \
        -row 1 -column 1 -rowspan 1 -columnspan 1 -sticky news -padx 1m

    label $LFrame.lowerText -text "Lower Bound" -anchor w
    grid $LFrame.lowerText -in $LFrame \
        -row 2 -column 0 -rowspan 1 -columnspan 1 -sticky news -padx 1m
    entry $LFrame.lower -textvariable ThisLower -bg white -width 10
    grid $LFrame.lower -in $LFrame \
        -row 2 -column 1 -rowspan 1 -columnspan 1 -sticky news -padx 1m

    label $LFrame.lengthText -text "Length" -anchor w
    grid $LFrame.lengthText -in $LFrame \
        -row 3 -column 0 -rowspan 1 -columnspan 1 -sticky news -padx 1m
    entry $LFrame.length -textvariable ThisLength -bg white -width 10
    grid $LFrame.length -in $LFrame \
        -row 3 -column 1 -rowspan 1 -columnspan 1 -sticky news -padx 1m

    label $LFrame.subgraphText -text "Subgraph" -anchor w
    grid $LFrame.subgraphText -in $LFrame \
        -row 4 -column 0 -rowspan 1 -columnspan 1 -sticky news -padx 1m
    entry $LFrame.subgraph -textvariable ThisSubgraph -bg white -width 10
    grid $LFrame.subgraph -in $LFrame \
        -row 4 -column 1 -rowspan 1 -columnspan 1 -sticky news -padx 1m

    grid rowconfig    $LFrame 0 -weight 1 -minsize 0
    grid columnconfig $LFrame 0 -weight 1 -minsize 0

pack $LFrame -side top -padx 10m -pady 5m
    
proc QualifiedArcAttrib {} {
    global ThisLength ThisUpper ThisLower ThisSubgraph
    if {$ThisLength==""} {return 0}
    if {$ThisUpper=="" || [expr $ThisUpper<0]} {return 0}
    if {$ThisLower=="" || [expr $ThisLower>$ThisUpper || $ThisUpper<0]} {return 0}
    if {$ThisSubgraph=="" || [expr $ThisSubgraph>$ThisUpper || $ThisSubgraph<$ThisLower]} {return 0}
    
    return 1
}

frame $DLabels.buttons
    button $DLabels.buttons.prev -text "Previous" -command {
        if {[QualifiedArcAttrib]} {
            UploadLabels
            global ThisArc ThisGraph
            incr ThisArc -1
            if {$ThisArc==-1} {
                set ThisArc [expr {[$ThisGraph #arcs]-1}]
            }
            DownloadArcLabels $ThisArc
        }
    }
    
    button $DLabels.buttons.next -text "Next" -command {
        if {[QualifiedArcAttrib]} {
            UploadLabels
            global ThisArc ThisGraph
            incr ThisArc
            if {$ThisArc==[$ThisGraph #arcs]} {
                set ThisArc 0
            }
            DownloadArcLabels $ThisArc
        }
    }
    
    button $DLabels.buttons.done -text "Done" -command {
        if {[QualifiedArcAttrib]} {
            UploadLabels
            destroy $DLabels
            InitBrowser
        }
    }
    
    pack $DLabels.buttons.prev $DLabels.buttons.next $DLabels.buttons.done \
        -side left -fill x -padx 3m
     
pack $DLabels.buttons -padx 3m -pady 3m -side bottom
