Hello monks who are always smarter than me. I have a script that I added a very simple Tcl::Tk GUI to a little while back. I've been trying to take it to the next level with drag and drop. I added the DND module to my Tcl installation and have drag and drop working but only using Tcl as you can see below. The code is from an example on line that I modified a little bit. It's my first time using the interp command. I thought EOS was to end that and I can drop my older GUI code in but I simply get a grey GUI with the spinning wheel and it never resolves. If I uncomment block 1 I get a new window with the list box. If I uncomment block 2, I get the word test in the GUI. I just don't see how to get the list box into the new GUI that has DND working. Any help would be greatly appreciated. My ugly code, as I'm still trying to work out this problem, is below:

use strict; use Tcl::Tk; my $mw = Tcl::Tk::tkinit; $mw->title("test"); $mw->interp->Eval(<<'EOS'); #. configure -height 550 #. configure -width 280 package require tkdnd catch {console show} pack [ttk::button .drop_target -text " Drop Target (I can accept anyth +ing!) "] \ -fill x -padx 20 -pady 20 pack [ttk::button .drop_target2 -text " Drop Target (I can accep +t anything!) "] \ -fill x -padx 20 -pady 20 tkdnd::drop_target register .drop_target DND_Files bind .drop_target <<Drop>> {puts "Generic data drop: \"%D\"! +!"; return %A} bind .drop_target <<Drop:DND_Text>> {puts "Dropped text: \"%D\""; re +turn %A} bind .drop_target <<Drop:DND_Files>> {puts "Dropped files: \"[join %D +{, }]\""; return %A} bind .drop_target <<Drop:DND_Files>> {file copy %D "cities.txt"} #split string %D,"," EOS #old GUI code - block #1 #my $int = new Tcl::Tk; #my $mw = $int->mainwindow; #$mw->title("test"); #my $frame_border_top = $mw->Frame( -relief => "flat" ); #testing code - block #1 #my $interp = $mw->interp; #my $lab_stat = $mw->Label(qw/-relief sunken -bd 1 -width 60 -text tes +t -anchor w/)->pack(qw/-side bottom -fill x/); #$mw->Frame(-height=>10)->pack(qw/-side bottom -fill x/); #more older GUI code #my $frame_border_top = $mw->Frame( -relief => "flat" ); # $frame_border_top->Label( -text => "test" ); #$frame_border_top->grid( -row => 1, -column => 1, -columnspan => 1 ); #$welcome_label->grid( -row => 1, -column => 1, -columnspan => 2); #listbox #################################### #user selects match type my @fuzzys = qw/ exact fuzzy/; my $lb3 = $mw->Listbox(-selectmode => 'single', ); $lb3->pack(-side => 'left', -fill => 'both'); $lb3->insert('end', sort @fuzzys); $lb3->bind('<Button-1>', { $lb3->curselection }); { $lb3->configure(-exportselection => 0)}; $lb3->grid( -row => 6, -column => 3, -columnspan => 1); #################################### #left over from example - save to study # Tcl inclusion for GUI finished here; you can work with widgets here +like: # my $lab = $mw->interp->widget('.status'); # $lab->configure(-text=>'new text here...'); Tcl::Tk::MainLoop;


In reply to Tcl DND working but can't get original Tcl::Tk GUI code to work by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.