Tk- getOpenFile sticks on W2K server

Discussion in 'Perl Misc' started by MoshiachNow, Sep 25, 2006.

  1. MoshiachNow

    MoshiachNow Guest

    HI,

    It works nicely on my XP,but sticks on W2K.

    Any suggestion for a better fileselct for Tk,or how to use getOpenFile
    on W2k ?

    Thanks
     
    MoshiachNow, Sep 25, 2006
    #1
    1. Advertising

  2. MoshiachNow

    zentara Guest

    On 25 Sep 2006 03:18:44 -0700, "MoshiachNow" <>
    wrote:

    >HI,
    >
    >It works nicely on my XP,but sticks on W2K.
    >
    >Any suggestion for a better fileselct for Tk,or how to use getOpenFile
    >on W2k ?
    >
    >Thanks



    Did you look at the requirements for ActiveStatePerl ( assuming that
    is what you are using)? W2k needs to be at Service Pack 5+.

    You can always write your own, like:

    #!/usr/bin/perl
    use strict;
    use Tk;
    require Tk::DirTree;
    require Tk::Adjuster;
    require Tk::TList;

    # The initial directory
    my $initial_dir = '/';

    # The main window...
    my $main = new MainWindow( -title => 'Explorer)' );

    # A frame for the tree, adjuster and tlist
    my $tree_adj_tablist = $main->Frame();
    $tree_adj_tablist->pack(
    -expand => 'yes',
    -fill => 'both',
    -side => 'top'
    );

    # A scrolled directory tree
    my $tree = $tree_adj_tablist->Scrolled(
    'DirTree',
    -width => 35,
    -height => 25,
    -scrollbars => 'osoe',
    -background => 'White',
    -selectmode => 'single',
    -selectbackground => 'DarkBlue',
    -selectforeground => 'White',
    -showhidden => 1,
    -directory => $initial_dir
    );
    $tree->pack(
    -expand => 'yes',
    -fill => 'both',
    -padx => 2,
    -pady => 2,
    -side => 'left'
    );

    # An adjuster
    my $adjuster = $tree_adj_tablist->Adjuster(
    -widget => $tree,
    -side => 'left'
    );
    $adjuster->pack( -side => 'left', -fill => 'y' );

    # A scrolled tab_list widget
    my $tab_list = $tree_adj_tablist->Scrolled(
    'TList',
    -background => 'White',
    -orient => 'vertical',
    -selectmode => 'extended',
    -scrollbars => 'os'
    );
    $tab_list->pack(
    -expand => 'yes',
    -fill => 'both',
    -padx => 2,
    -pady => 2,
    -side => 'right'
    );


    # Ok button
    my $ok = $main->Button(
    -text => 'Ok',
    -underline => 0,
    -width => 4,
    -command => sub { my $selected = $tab_list->info('selection');
    #print "@{$selected}\n";
    foreach( @{$selected} ){
    print $tab_list->entrycget($_, '-text'),"\n";
    }
    })->pack( -side => 'right', -padx => 10, -pady => 10 );


    # A Quit button (will be suppressed???...)
    my $quit = $main->Button(
    -text => 'Quit',
    -underline => 0,
    -width => 6,
    -command => sub { exit }
    );
    $quit->pack( -side => 'right', -padx => 10, -pady => 10 );

    # Configuring tree and tab_list widgets...
    $tree->configure( -browsecmd => sub { list_dir( $tab_list, @_ ); } );

    # We list the content of the initial dir inside the tab_list
    list_dir( $tab_list, $initial_dir );

    MainLoop();

    #----------------------------------------------------------------------------

    # Displays Dirs and files in TList widget
    sub list_dir {
    my ( $tab_list, $path ) = @_;

    # Erase the TList content
    $tab_list->delete( 0, 'end' );

    opendir MY_DIR, $path or return;

    foreach my $file ( sort readdir(MY_DIR) ) {

    # Do not display '.' and '..'
    next if ( $file eq '.' or $file eq '..' );

    # Insert the files in the TList
    $tab_list->insert( 'end', -text => $file );
    }
    closedir MY_DIR;
    }

    __END__


    --
    I'm not really a human, but I play one on earth.
    http://zentara.net/japh.html
     
    zentara, Sep 25, 2006
    #2
    1. Advertising

  3. MoshiachNow

    MoshiachNow Guest

    Great !!!
    Thanks
     
    MoshiachNow, Sep 25, 2006
    #3
  4. MoshiachNow

    MoshiachNow Guest

    # The initial directory
    my $initial_dir = '/';


    How do I cause the browser to see all disks from the top,not only my
    current disk ?
    Thanks
     
    MoshiachNow, Sep 26, 2006
    #4
  5. MoshiachNow

    zentara Guest

    On 25 Sep 2006 22:42:00 -0700, "MoshiachNow" <>
    wrote:

    ># The initial directory
    >my $initial_dir = '/';
    >
    >
    >How do I cause the browser to see all disks from the top,not only my
    >current disk ?
    >Thanks


    Well I use linux, and '/' is the top. All other disks have to be mounted
    somewhere on /.

    If you are using Windows, I don't know how they do it.


    --
    I'm not really a human, but I play one on earth.
    http://zentara.net/japh.html
     
    zentara, Sep 26, 2006
    #5
  6. MoshiachNow

    David Harmon Guest

    On Tue, 26 Sep 2006 10:20:05 GMT in comp.lang.perl.misc, zentara
    <> wrote,
    >Well I use linux, and '/' is the top. All other disks have to be mounted
    >somewhere on /.
    >
    >If you are using Windows, I don't know how they do it.


    use Win32API::File ("getLogicalDrives");
    @roots= getLogicalDrives()
     
    David Harmon, Oct 2, 2006
    #6
  7. MoshiachNow

    MoshiachNow Guest


    >
    > use Win32API::File ("getLogicalDrives");
    > @roots= getLogicalDrives()


    Thanks,

    but I need a GUI window for user to browse it ...
     
    MoshiachNow, Nov 16, 2006
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VB Programmer

    Question: W2K - ok to use as web server?

    VB Programmer, Jul 21, 2003, in forum: ASP .Net
    Replies:
    13
    Views:
    527
  2. Mathew
    Replies:
    4
    Views:
    1,755
    Matt Vording
    Dec 3, 2003
  3. =?Utf-8?B?UG9va3k=?=

    Advice on W2K Server setup

    =?Utf-8?B?UG9va3k=?=, May 19, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    339
    =?Utf-8?B?UG9va3k=?=
    May 19, 2004
  4. NES

    JApplet: Button Sticks!

    NES, Aug 4, 2005, in forum: Java
    Replies:
    2
    Views:
    498
    Andrew Thompson
    Aug 4, 2005
  5. James Dow Allen

    Re: cutting sticks problem

    James Dow Allen, May 9, 2008, in forum: C Programming
    Replies:
    3
    Views:
    461
    Greg Herlihy
    May 12, 2008
Loading...

Share This Page