Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Open a folder

by jerre_111 (Sexton)
on Mar 21, 2013 at 09:53 UTC ( #1024697=perlquestion: print w/ replies, xml ) Need Help??
jerre_111 has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks, I want to ask you advice on something

I'm making a program where I alter some images. I have made a GUI with the TK module.

After you hit the button to finish the conversion a dialog box pops up like this:

$converted = $mw->Dialog(-title => ' Conversion', -text => 'The conversion is completed', -default_button => 'open file', -buttons => [ 'open file', 'close'] +, -bitmap => 'info' )->Show( );

But now I'm looking for a way to open a window of your filemanager where you can view your new image at the right folder location

I know about the  getOpenFile() commando, but that is to open a file. I just want to open a window of the filemanager at the new image location.

I am working on a unix environment so I'm not looking for solutions on win.

so summarized, when you hit the open file button on the dialog box, a window of file manager opens up at the location of the new image, which is already given elsewhere in the program.

Any ideas how to do this? can't seem to find it.

Thanks in advance

Comment on Open a folder
Select or Download Code
Re: Open a folder
by jethro (Monsignor) on Mar 21, 2013 at 11:49 UTC

    Do you really mean a file manager like dolphin or midnight commander? In that case you have to use system() to call them. They should allow a filename as parameter

    Or are you asking about the file selector box? In that case although getOpenFile() writes "Open" somewhere into the box it just gives back a filename so you can do anything with it. You don't need to open it.

    Googling also unearthed Tk::FileDialog on CPAN, maybe this is what you want

      Yes, I mean a file manager like that, I'm using the "thunar" file manager.

      But if i call them with "system()", I guess that on another pc without Thunar, nothing will happen? or worst case an error will appear?

      I don't want a file selector thank you. To say it in "windows words", I want to open explorer at the position where my new image is located.

      I already have the Path where the new image is located from a dialog box off getSaveFile(). So I want to say, open explorer at that path. But then in unix except windows.

        So if you were using MS Windows I'd advise you to use something like start $directory, where $directory is the path you wish to open. Now depending on your window manager the equivalent method could be many things, for example for xfce xdg-open $directory, gnome-open $directory, kde-open $directory and so on. So you're going to have to figure out the details of the end user platform (unless this is for a specific target that you know about), and cater for each accordingly.

        Update: you may want to play around with the following basic example:

        #!/usr/bin/perl use strict; use warnings; my $wm = $ENV{'XDG_CURRENT_DESKTOP'}; print "Window Manager: $wm"; # later on, call specific system command for the running window manage +r

        So your problem is to find a suitable file manager on any linux box.

        It seems xdg-open will do what you want. On my machine it opens dolphin if I call "xdg-open ."

        There also might be methods to find standard applications in window managers like gnome or kde, but I'm just guessing. Probably they just use xdg-open too

        If nothing works you could have a list of filemanagers in your script that you simply check if they are installed.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1024697]
Approved by marto
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2014-07-13 09:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (249 votes), past polls