Perl/Tk - user value


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl/Tk - user value
# 1  
Old 09-14-2011
Question Perl/Tk - user value

Hi,

I am new to perl TK world.

I am having doubt that for the below code.

How to take the value of selected and text box value from out of the loop.




Code:
#!/usr/bin/perl
use strict;
use Tk;
use Tk::BrowseEntry;
my $mw = MainWindow->new;

# Mainwindow: sizex/y, positionx/y
$mw->geometry("400x400+100+120");

&create_dropdown($mw);
my $mid_value;
$mid_value= \&create_dropdown_dit();
&create_dropdown_bot($mw);

#$ref = \&getGlobalName();

MainLoop;

sub create_dropdown {
    my $toplam  = shift;
    # Create dropdown and another element which shows my selection
    my $dropdown_value;
    my $dropdown = $toplam->BrowseEntry(
        -label => "Label",
        -variable => \$dropdown_value,
        )->place( -x => 100, -y => 15);
    my $showlabel = $toplam->Label(
        -text => "nothing selected",
        )->place( -x => 280, -y => 15);

    # Configure dropdown
    $dropdown->configure(
        # What to do when an entry is selected
        -browsecmd => sub {
            $showlabel->configure(-text => "You selected: $dropdown_value" ),
        },
    );

    # Populate dropdown with values
    foreach ( qw/apple banana pineapple grape/ ) {
        $dropdown->insert('end', $_);
    }
    # Set the initial value for the dropdown
    $dropdown_value = "Top value";
}



sub create_dropdown_bot {
    my $botlam  = shift;
    # Create dropdown and another element which shows my selection
    my $dropdown_value_bot;
    my $dropdownbot = $botlam->BrowseEntry(
        -label => "Label",
        -variable => \$dropdown_value_bot,
        )->place( -x => 100, -y => 75);
    my $showlabel = $botlam->Label(
        -text => "nothing selected",
        )->place( -x => 280, -y => 75);

    # Configure dropdown
    $dropdownbot->configure(
        # What to do when an entry is selected
        -browsecmd => sub {
            $showlabel->configure(-text => "You selected: $dropdown_value_bot" ),
        },
    );

    # Populate dropdown with values
    foreach ( qw/apple banana pineapple grape/ ) {
        $dropdownbot->insert('end', $_);
    }
    # Set the initial value for the dropdown
    $dropdown_value_bot = "Bottom value";
}


sub create_dropdown_dit {
    #my $di_thick  = shift;
    # Create dropdown and another element which shows my selection
    #my $di_thick_value;
    
    # A label to show what to type in
    my $label_wert = $mw->Label( 
        -text => 'mid value:',
    )->place( -x => 30, -y => 45);

    # This is the text-userinput field
    my $entry_wert = $mw->Entry( 
        # width is in characters, not pixel
        -width => 20,
    )->place( -x => 130, -y => 45);
    

    my $submit_but = $mw->Button(
    -text => "Execute",
    # call a sub somewhere
    -command => \&submit_action,
    )->place( -x => 130, -y => 135);
    
}




print $mid_value


Like mid_value i need to see after the loop.

Thanks in advance,
K.Vasanth
# 2  
Old 09-16-2011
TK variable in perl

Hi Guys,

I have used some variable in Tk.

And it is not getting used of outside mainloop();

How to get the variable value out of mainloop


Thanks
Vasanth
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl to read user input

I am creating a bash that uses perl . The below code closes before the input is entered. If I run the perl as a .pl it is fine. What am I doing wrong? Thank you :). #!/bin/bash cd 'C:\Users\cmccabe\Desktop\wget' wget -O getCSV.txt http://xxx.xx.xxx.xxx/data/getCSV.csv print... (4 Replies)
Discussion started by: cmccabe
4 Replies

2. Shell Programming and Scripting

User prompt for perl

perl -aF/\\t/ -lne 'BEGIN{%m=map{chomp;s/\cM|\cJ//g;$p=join("\t",(split/\t/));($p,$_)} <>;$m{"#CHROM\tINFO"}=$m{"Chr\tSegment Position"}};/SEGPOS=(\d+)/ || /\t(INFO)\t/ or next;$p=$F."\t".$1;exists $m{$p} and print join("\t",$_,$m{$p})' 12345_Marfan20_Output_Mutation_Report.txt <... (3 Replies)
Discussion started by: cmccabe
3 Replies

3. Shell Programming and Scripting

User input in perl code

Hello friends . I am newbie to perl scripting but still managed to write a code but i am stuck at a place where i need help . Below is the code and can someone help me in taking user input for changing the font size for a html table .Thank you in advance #!/bin/ksh echo " Enter the Directory... (4 Replies)
Discussion started by: ajayram_arya
4 Replies

4. Shell Programming and Scripting

user input in perl?

Please tell me how to write a perl script that asks the user to enter words and that passes them to a variable. In bash, the "read" command would achieve such user interaction. #!/bin/bash read -p "Enter files: " vFiles However, I am looking for perl version of something equivalent... (2 Replies)
Discussion started by: LessNux
2 Replies

5. Shell Programming and Scripting

User input - Perl need Help

If I want all user input to start with " : " if not display error or what I asking is how to do if statement that control a first letter of string that we want to start with. and not worry about the rest Thank (1 Reply)
Discussion started by: guidely
1 Replies

6. Shell Programming and Scripting

switch user from local user to root in perl

Hi Gurus, I have a script that requires me to switch from local user to root. Anyone who has an idea on this since when i switch user to root it requires me to input root password. It seems that i need to use expect module here, but i don't know how to create the object for this. ... (1 Reply)
Discussion started by: linuxgeek
1 Replies

7. Shell Programming and Scripting

Perl LWP user authentication

Hello all.. i am new to perl scripting.. i wanted to parse a text file, encode the parsed text and attach in url.. please point me to right resources if you know any..This is my major problem. Now i try to get a url running and save it in a text file using LWP module in perl, I used following... (0 Replies)
Discussion started by: empyrean
0 Replies

8. Post Here to Contact Site Administrators and Moderators

e-mail sent to user about PERL

Is there a way to setup an e-mail job (thru my account) to send me e-mail every time a new question or response to PERL is entered into a forum? thanks, djehresmann (1 Reply)
Discussion started by: djehresmann
1 Replies

9. Shell Programming and Scripting

create an user in perl

hi friends, i want to create an new user in my home directory , only just for checking. if it is possible, please help me. thanks (1 Reply)
Discussion started by: praneshbmishra
1 Replies

10. Shell Programming and Scripting

How to scp as different user in perl script

Hi, I am writing a perl script that needs to change to a another user and scp files to a remote server. The passwords should not be prompted but read from a config file. Please help. Thanks Sandeep (4 Replies)
Discussion started by: sdubey
4 Replies
Login or Register to Ask a Question