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

I'm trying to convert a Perl/Tk script to Perl/Tkx and I'm not sure how DND works in Tkx. Can someone please advise me on how to do that? I created a simple Perl/Tk script (below) and was wondering if someone could convert it to Tkx. Thank you in advance. David
use strict; use Tk; use Tk::Pane; my $textVariable = "my text"; my $mw = MainWindow->new; my $frame = $mw->Frame()->pack(-side => 'top', -expand => 1, -fill => +'x'); $frame->Label(-text => "My Label", -anchor => 'w', -width => 10)->pack(-ipady => 1, -side => 'left'); my $entry = $frame->Entry(-textvariable => \$textVariable, -width => 40)->pack(-side => 'left'); $frame->DropSite(-dropcommand => [\&AcceptDrop, $frame], -droptypes => ('Win32')); MainLoop; sub AcceptDrop { my ($widget, $selection) = @_; my $filename; $filename = $widget->SelectionGet(-selection => $selection, 'STRIN +G'); $textVariable = $filename; }

Replies are listed 'Best First'.
Re: Drag and Drop in Tkx
by Anonymous Monk on Jan 25, 2010 at 16:34 UTC
      Thanks for the response, but does that mean I need to somehow figure out how to convert TCL to Perl/Tkx? Is there a way to get a little bit more help? I've searched for Tkx examples of drag and drop and haven't found any examples. I converted my simple example to use Tkx and I get an error:
      bad option "DropSite": must be cget or configure at D:\dss\perl\tk\tkx +\dnd.pl line 18.
      So, I assume I can't do it the same way, and simply have
      $frame->DropSite(-dropcommand => [\&AcceptDrop, $frame], -droptypes => ('Win32'));
        perldoc Tkx
        ...

        The main idea behind Tkx is that it is a very thin wrapper on top of Tcl, i.e. that what you get is exactly the behaviour you read about in the Tcl/Tk documentation with no surprises added by the Perl layer.

        This is the "reference manual" for Tkx. For a gentle introduction please read the Tkx::Tutorial. The tutorial at http://www.tkdocs.com/tutorial/ is also strongly recommened.

Re: Drag and Drop in Tkx
by zentara (Cardinal) on Jan 26, 2010 at 11:43 UTC
    To make your struggle seem easier, remember that Drag-n-Drop is one of the hardest tricks to implement in a bug free manner. That is why you see very few good working examples. So if you do succeed... post a working demo, for the people seeking later. :-)

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku
      The Perl/Tk version of my script seems fine as far as drag-n-drop. Just can't decipher the Perl/Tkx way to do it. Might have to abandon my attempts and stick with what I have with Tk. This is taking too much time away from my real job! I will definitely post something once I know how to do it. I've seen too many posts where someone will have a problem, get some help and then they'll announce that they solved it, leaving everyone else up in the air as far as the solution.
        As an update, I still don't know how to use drag and drop in Tkx. Some of the suggestions don't really help. The BWidget example: Drag and Drop Demo, is in TCL not Perl. It is not clear how to convert from TCL to Perl/Tkx, especially in terms of drag and drop. The gentle introduction at Tkx:Tutorial doesn't mention drag and drop. The tutorial at www.tkdocs.com/tutorial does not explain how to do drag and drop and I contacted the tutorial's author and he said:

        "I'm not aware of any specific info about drag and drop in Tkx. Because it isn't a standard part of Tk, it's not automatically made a part of Tkx like the built-in Tk things are."

        It was suggested that I sent a query to tcltk@perl.org, which I did, but didn't hear anything back. Any additional help would be appreciated.