Greetings: I am new to PERL (1 year) but even newer to TK (1 week or so). Here is my problem...... I have a PERL program that creates a nice window, adds some radio buttons, a status Label widget, and a 'go' Button. What I am wanting to do -- when the 'go' Button is clicked, the program will disable the radio buttons, get the directory listing from differnt directories, and update the Label widget with the number of files found. What happens is the main window freezes until the all the directories have been parsed. Note the code snippet below has a lot of the overhead removed. I don't think it will run on its own. Sorry if it is forbidden to post unworking code. I just wanted everyone to see the setup.
use Tk; # TK Setup #Window Creation $main = MainWindow -> new(); #Create Main Window Object $main -> minsize(qw(500 250)); #Size window $main -> configure(-background => 'blue');#Set Background Color #add go button $button_1 = $main -> Button(-text => "GO", -padx => 25, -foreground => "white", -background => "green", -command => \&go)-> pack(-side => 'bottom', -anchor => + 's', expand => 'yes'); #Add main center frame $left_3 = $main -> Frame(-relief => 'groove', -borderwidth => 3, -background => 'blue')-> pack(-side => 'botto +m',-anchor => 'n', -fill => 'x'); #added buttons to the frames (removed for this) #add label to center frame $label_3 = $left_3 -> Label(-text => "Status", -background => 'blue', -relief => 'raised', -borderwidth => 3, -foreground => 'white')->pack(-fill => 'x', -anchor => + 'w', expand => 1); $text = $left_3->Label(-textvariable => \$var)->pack(-anchor => ‘w’); + MainLoop(); sub go { #freeze the selections for $i (1..6){$check_button[$i] -> configure(-state => 'disabled') +;} # get info from dictionary files while(($folder, $drive) = each %search_locations) { #get list of files in directory $var = "Looking in - $drive/DICT/SOURCE\n"; chdir "$drive/variable/DICT/SOURCE"; @file_list = glob ("*.dsf"); $var = “Num of files: $#file_list”; } }
I hope this makes sense. What I am wanting is for $var to change in the Label widget as the program processes the while loop. Some other notes, the directories are large (>1000 files). To me, it seems the program is hung during the glob function. The only time the main window updates is when the while loop is complete. Thoughts? keep in mind..newbie here...so.. be nice with the criticism....

In reply to Newbie with a TK question by hebes_99

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.