Essentially, you'd need to service both message queues concurrently. Tk has calls that allow you to service it's queue without entering MainLoop, but there probably isn't any effective way to call them once you've entered the native control's dispatch loop.
It would be worth trying invoking the ShBrowseForFolder() api from within a thread:
use threads;
asynch {
ShBrowseForFolder( ... );
}->detach;
That should allow the main thread to run the Tk MainLoop concurrently with the Native controls dispatch loop.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] [d/l] |
| [reply] |
but the app breaks shortly after since Tk is not thread safe
Then only use Tk from one thread. Really, it works just fine.
If you'd care to post your working but crashing code, I'll show you how to stop it from crashing.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] |
| [reply] |
| [reply] [d/l] |
| [reply] |
| [reply] [d/l] |
Gtk2 has a nice file browser too, it's the same one you get with any Gtk2 app, like firefox, gimp, etc. It has an "Add" Button which allows you to make new directories, as per your pic above.
#!/usr/bin/perl
use strict;
use warnings;
use Gtk2 '-init';
my $window = Gtk2::Window->new;
$window->set_title("File Selector");
$window->signal_connect( destroy => sub { Gtk2->main_quit; } );
my $button = Gtk2::Button->new("Select");
$button->signal_connect( clicked => \&dir_selector );
$window->add($button);
$window->show_all();
Gtk2->main;
sub dir_selector {
my $d = Gtk2::FileChooserDialog->new(
'Choose a Directory',
$window, 'select-folder',
"Cancel" => "cancel",
"OK" => "accept",
);
my $response = $d->run();
if ( "accept" eq $response ) {
print $d->get_filename(), "\n";
}
$d->destroy;
}
| [reply] [d/l] |