Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
Don't ask to ask, just ask
 
PerlMonks  

Re: itemconfigure in listbox (Tk)

by thundergnat (Deacon)
on Mar 12, 2013 at 12:57 UTC ( #1022975=note: print w/ replies, xml ) Need Help??


in reply to itemconfigure in listbox (Tk)

(Written before you showed your code) Probably the reason is that readdir just returns the file name. If you want to do file tests on the file, you need to include the path... like so:

#!/usr/bin/perl use warnings; use strict; use Tk; my %tk; $tk{mw} = MainWindow->new; $tk{frame} = $tk{mw}->Frame->pack( -expand => 1, -fill => 'both', -anchor => 'nw' ); $tk{listbox} = $tk{frame}->Scrolled( 'Listbox', -selectmode => 'single', -scrollbars => 'ose', )->pack( -expand => 1, -fill => 'both', -padx => 5, -pady => 5, ); my $dir = q|/|; readDir($dir); MainLoop; sub readDir{ my $dir = shift; opendir(my $dh, $dir) or die "Can't opendir $dir: $!"; my @all = readdir($dh); for my $x (sort (@all)){ next if($x =~ /^\.$/); $tk{listbox}->insert('end', $x); if(-d $dir.$x){ print "$x\n"; $tk{listbox}->itemconfigure($tk{listbox}->size()-1, -foreg +round=>"#F00"); } } close $dh; }


Comment on Re: itemconfigure in listbox (Tk)
Download Code
Re^2: itemconfigure in listbox (Tk)
by ch4inm4n (Novice) on Mar 12, 2013 at 13:10 UTC
    Thank you very much :)
    Now everything works fine

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1022975]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2014-04-20 21:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (488 votes), past polls