Janish has asked for the wisdom of the Perl Monks concerning the following question:

Hi greetings,

I wish to enhance my Perl/Tk script so that to develop a feature so that it can load or pop open a file while user click on the path (something like a hyperlink). How could I do this in Perl/TK? Can someone point me to the right reference with an example preferably? I refer to this one (http://www.perlmonks.org/bare/?node_id=335717) but I just not too sure how to apply it in my actual script. What I want is just to state a path in the log report which user can just click to auto load the file up for convenient reading, where user no need to gvim or open it in xterm manually. Thank you

Replies are listed 'Best First'.
Re: How to load a file in Perl/Tk
by Discipulus (Canon) on Oct 19, 2015 at 06:46 UTC
    hi Janish

    Hyperlink does not exists in Perl\Tk. You can easily add a dropdown list of file and a 'load' button, but is not an hyperlink. That said if you have enough creativity and some skill you can mimicry the hyperlink beahviour.

    In fact in the thread you cite there is the zentara's answer that exactly mimic the hyperlink's aspect and behaviour; you just need to modify the manipulate_link sub to do what you need.

    Take in count that zentara was probably the best Tk monk ever apperead in the cloister so maybe a dedicated search of his works may be worth (results leads to other 5 answers).

    HtH
    L*
    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

      Thank you Discipulus, your reply at least let me know that there is no such feature in Perl/Tk. Zentara sample is great, but it's just my problem not sure how to implement that in my script, still.. I hope someone could shows me guide with sample that could help me to have clearer picture.

        Look Janish at the moment i have no time to produce a full, working Tk example but you have a lot of possibilities. First of them you can create so called hyperlink (as in zentara example) and modify the sub to spawn another windows where the file content is showed. see Displaying text file with perl/tk for an example.
        You can also, if nasty, make a system call to open the editor of choice with the path as argoument.

        L*
        There are no rules, there are no thumbs..
        Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
Re: How to load a file in Perl/Tk
by Anonymous Monk on Oct 19, 2015 at 07:40 UTC

    but I just not too sure how to apply it in my actual script.

    Why not (this means explain the confusion if you want help)?

    tk html
    -> Tk::MarkdownTk - a Tk::Markdown with tk widget tag support
    -> Tk::HyperText - An ROText widget which renders HTML code.