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;
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |