我是新手,我遇到了问题。我试图通过
- 函数中的可变字段。我有一个下拉
-variable => \$fever
我也有-command => [\&show_choice, \$fever]
..我正在尝试打印所选下拉选项的值。但我得到的是像SCALAR(0X765 ......)。如何获得显示的值?我尝试使用-textVariable而不是变量,但工作方式相同。
以下是代码:
#!/usr/bin/perl
use Data::Printer;
use warnings;
use Tk;
my $mw = MainWindow->new;
$mw->geometry("700x700");
$mw->title("AIR (Auto Immune Research)");
#create own title font
$mw->fontCreate("sectionTitleFont", -family => "Helvetica", -size => 36, -weight => "bold");
my $symptomFrame = $mw->Frame(-background => 'white', -foreground => 'black')->pack(-side => "top", -fill => "x");
my $pathologyFrame = $mw->Frame(-background => 'white', -foreground => 'black')->pack(-side => "bottom", -fill => "x");
my $symptomLabel = $symptomFrame->Label(-background => 'white', -text => 'Patient Symptoms', -font => 'sectionTitleFont');
my $pathologyLabel = $pathologyFrame->Label(-background => 'white', -text => 'Pathological Findings', -font => 'sectionTitleFont');
my $severityText = $symptomFrame->Label(-background => 'white', -text => 'Intensity');
#cough
my $coughCheckBox = $symptomFrame->Checkbutton(-text => 'Cough', -background => 'white', -variable => \$couchCheck);
my $coughSeverity;
my $coughSeverityDD = $symptomFrame->Optionmenu(
-options => [[1=>1], [2=>2], [3=>3], [4=>4], [5=>5], [6=>6], [7=>7], [8=>8], [9=>9], [10=>10]],
-variable => \$coughSeverity,
-command => [\&show_choice, $coughSeverity, "cough", \$couchCheck]
);
#Fever
my $feverCheckBox = $symptomFrame->Checkbutton(-text => 'Fever', -background => 'white', -variable => \$feverCheck);
my $feverSeverity;
my $feverSeverityDD = $symptomFrame->Optionmenu(
-options => [[1=>1], [2=>2], [3=>3], [4=>4], [5=>5], [6=>6], [7=>7], [8=>8], [9=>9], [10=>10]],
-variable => \$feverSeverity,
-command => [\&show_choice, $feverSeverity, "fever", \$feverCheck]
);
#joint pain
my $jointPainCheckBox = $symptomFrame->Checkbutton(-text => 'Joint Pain', -background => 'white', -variable => \$jointPainCheck);
my $jointPainSeverity;
my $jointPainSeverityDD = $symptomFrame->Optionmenu(
-options => [[1=>1], [2=>2], [3=>3], [4=>4], [5=>5], [6=>6], [7=>7], [8=>8], [9=>9], [10=>10]],
-variable => \$jointPainSeverity,
-command => [\&show_choice, $jointPainSeverity, "joint pain", \$jointPainCheck]
);
#Moon face
my $moonFaceCheckBox = $symptomFrame->Checkbutton(-text => 'Moon Face', -background => 'white', -variable => \$moonFaceCheck);
my $moonFaceSeverity;
my $moonFaceSeverityDD = $symptomFrame->Optionmenu(
-options => [[1=>1], [2=>2], [3=>3], [4=>4], [5=>5], [6=>6], [7=>7], [8=>8], [9=>9], [10=>10]],
-variable => \$moonFaceSeverity,
-command => [\&show_choice, $moonFaceSeverity, "moon face", \$moonFaceCheck]
);
#fatigue
my $fatigueBox = $symptomFrame->Checkbutton(-text => 'Fatigue', -background => 'white', -variable => \$fatigueCheck);
my $fatigueSeverity;
my $fatigueSeverityDD = $symptomFrame->Optionmenu(
-options => [[1=>1], [2=>2], [3=>3], [4=>4], [5=>5], [6=>6], [7=>7], [8=>8], [9=>9], [10=>10]],
-variable => \$fatigueSeverity,
-command => [\&show_choice, $fatigueSeverity, "fatigue", \$fatigueCheck]
);
#Skin Redness
my $skinRednessBox = $symptomFrame->Checkbutton(-text => 'Skin Redness', -background => 'white', -variable => \$skinRednessCheck);
my $skinRednessSeverity;
my $skinRednessSeverityDD = $symptomFrame->Optionmenu(
-options => [[1=>1], [2=>2], [3=>3], [4=>4], [5=>5], [6=>6], [7=>7], [8=>8], [9=>9], [10=>10]],
-variable => \$skinRednessSeverity,
-command => [\&show_choice, $skinRednessSeverity, "skin redness", \$skinRednessCheck]
);
#Drowsiness
my $drowsinessBox = $symptomFrame->Checkbutton(-text => 'Drowsiness', -background => 'white', -variable => \$drowsinessCheck);
my $drowsinessSeverity;
my $drowsinessSeverityDD = $symptomFrame->Optionmenu(
-options => [[1=>1], [2=>2], [3=>3], [4=>4], [5=>5], [6=>6], [7=>7], [8=>8], [9=>9], [10=>10]],
-variable => \$drowsinessSeverity,
-command => [\&show_choice, $drowsinessSeverity, "drowsiness", \$drowsinessCheck]
);
#Headache
my $headacheBox = $symptomFrame->Checkbutton(-text => 'Headache', -background => 'white', -variable => \$headacheCheck);
my $headacheSeverity;
my $headacheSeverityDD = $symptomFrame->Optionmenu(
-options => [[1=>1], [2=>2], [3=>3], [4=>4], [5=>5], [6=>6], [7=>7], [8=>8], [9=>9], [10=>10]],
-variable => \$headacheSeverity,
-command => [\&show_choice, $headacheSeverity, "headache", \$headacheCheck]
);
#Inflamations
my $inflamationsBox = $symptomFrame->Checkbutton(-text => 'Inflamations', -background => 'white', -variable => \$inflamationsCheck);
my $inflamationsSeverity;
my $inflamationsSeverityDD = $symptomFrame->Optionmenu(
-options => [[1=>1], [2=>2], [3=>3], [4=>4], [5=>5], [6=>6], [7=>7], [8=>8], [9=>9], [10=>10]],
-variable => \$inflamationsSeverity,
-command => [\&show_choice, $inflamationsSeverity, "inflamations", \$inflamationsCheck]
);
#Itchiness
my $itchinessBox = $symptomFrame->Checkbutton(-text => 'Itchiness', -background => 'white', -variable => \$itchinessCheck);
my $itchinessSeverity;
my $itchinessSeverityDD = $symptomFrame->Optionmenu(
-options => [[1=>1], [2=>2], [3=>3], [4=>4], [5=>5], [6=>6], [7=>7], [8=>8], [9=>9], [10=>10]],
-variable => \$itchinessSeverity,
-command => [\&show_choice, $itchinessSeverity, "itchiness", \$itchinessCheck]
);
#Blood in Urine
my $bloodBox = $symptomFrame->Checkbutton(-text => 'Blood in Urine', -background => 'white', -variable => \$bloodCheck);
my $bloodSeverity;
my $bloodSeverityDD = $symptomFrame->Optionmenu(
-options => [[1=>1], [2=>2], [3=>3], [4=>4], [5=>5], [6=>6], [7=>7], [8=>8], [9=>9], [10=>10]],
-variable => \$bloodSeverity,
-command => [\&show_choice, $bloodSeverity, "blood in urine", \$bloodCheck]
);
#Depression
my $depressionBox = $symptomFrame->Checkbutton(-text => 'Depression', -background => 'white', -variable => \$depressionCheck);
my $depressionSeverity;
my $depressionSeverityDD = $symptomFrame->Optionmenu(
-options => [[1=>1], [2=>2], [3=>3], [4=>4], [5=>5], [6=>6], [7=>7], [8=>8], [9=>9], [10=>10]],
-variable => \$depressionSeverity,
-command => [\&show_choice, $depressionSeverity, "depression", \$depressionCheck]
);
#Sleep Deprevity
my $sleepDeprevityBox = $symptomFrame->Checkbutton(-text => 'Sleep Deprevity', -background => 'white', -variable => \$sleepCheck);
my $sleepDeprevitySeverity;
my $sleepDeprevitySeverityDD = $symptomFrame->Optionmenu(
-options => [[1=>1], [2=>2], [3=>3], [4=>4], [5=>5], [6=>6], [7=>7], [8=>8], [9=>9], [10=>10]],
-variable => \$sleepDeprevitySeverity,
-command => [\&show_choice, $sleepDeprevitySeverity, "sleep deprevity", \$sleepCheck]
);
#emty label to give empty space
my $emptyLabel = $symptomFrame->Label(-background => 'white', -width => '20');
$symptomLabel->grid(-columnspan => '5');
$pathologyLabel->grid(-columnspan => '5');
#$severityText->grid;
$coughCheckBox -> grid($severityText, $coughSeverityDD, $emptyLabel, $feverCheckBox, $severityText, $feverSeverityDD);
$sleepDeprevityBox -> grid($severityText, $sleepDeprevitySeverityDD, $emptyLabel, $depressionBox, $severityText, $depressionSeverityDD);
$moonFaceCheckBox -> grid($severityText, $jointPainSeverityDD, $emptyLabel, $bloodBox, $severityText, $bloodSeverityDD);
$itchinessBox -> grid($severityText, $itchinessSeverityDD, $emptyLabel, $inflamationsBox, $severityText, $inflamationsSeverityDD);
$headacheBox -> grid($severityText, $headacheSeverityDD, $emptyLabel, $drowsinessBox, $severityText, $drowsinessSeverityDD);
$skinRednessBox -> grid($severityText, $skinRednessSeverityDD, $emptyLabel, $fatigueBox, $severityText, $fatigueSeverityDD);
sub show_choice
{
#my $severity_value = p($_[0]);
#$severity_value =~ s/.*\W(\w)/$1/;
#p($severity_value);
#my $symptom = $_[1];
#my $checkVal = p($_[2]);
#$checkVal =~ s/.*\W(\w)/$1/;
#print "$severity_value \n";
my $val = $_[0];
print "$val \n";
return;
}
#$fatigueBox -> grid($fatigueSeverityDD, $emptyLabel, $itchinessBox, $dd3);
#$moonFaceCheckBox -> grid($jointPainSeverityDD, $emptyLabel, $bloodCheckBox, $dd3);
#$moonFaceCheckBox -> grid($jointPainSeverityDD, $emptyLabel, $bloodCheckBox, $dd3);
#$moonFaceCheckBox -> grid($jointPainSeverityDD, $emptyLabel, $bloodCheckBox, $dd3);
#$moonFaceCheckBox -> grid($jointPainSeverityDD, $emptyLabel, $bloodCheckBox, $dd3);
#$moonFaceCheckBox -> grid($jointPainSeverityDD, $emptyLabel, $bloodCheckBox, $dd3);
#$moonFaceCheckBox -> grid($jointPainSeverityDD, $emptyLabel, $bloodCheckBox, $dd3);
MainLoop;
答案 0 :(得分:0)
SCALAR(0X765...)
的输出表示对标量的引用而不是简单的标量。我想您希望将$fever
直接传递给您的命令,而不是参考\$fever
。
-command => [ \&show_choice, $fever ]