require Tk;
package Varwatcher;
sub new {
    local($w, $label, $watchref) = @_;
    local($f) = Frame::new($w, "-relief" => "ridge");
    local($labelw) = Label::new($f);
    local($watchw) = Label::new($f);
    $labelw->configure("-text" => $label) if defined $label;
    $watchw->configure("-textvariable" => $$watchref) if defined $watchref;
    Tk::tkpack $labelw, $watchw, "-side" => "left";
    return bless({Default => $f, "label" => $labelw, "watch" => $watchw});
}

sub label {
    local($w, $label) = @_;
    if (defined($label)) {
        $w->{"label"}->configure("-text" => $label);
    } else {
        return $w->{"label"}->configure("-text");
    }
}

sub watch {
    local($w, $watchref) = @_;
    $w->{"watch"}->configure("-textvariable" => $$watchref);
}

1;
