Here you go, adapted from this pythong example
package main; my ($app) = MyApp->new(); $app->MainLoop(); package MyApp; use base qw(Wx::App); sub OnInit { my ($self) = shift; my ($frame) = MyFrame->new; $frame->Show(1); $self->SetTopWindow($frame); return 1; } package MyFrame; use Wx::Perl::Carp; use Wx; use base 'Wx::Frame'; sub new { my $class = shift; my $self = $class->SUPER::new( undef, -1, 'Hiya there' ); my $panel = Wx::Panel->new( $self, -1 ); use Wx qw' wxLB_SINGLE '; $self->{lb1} = Wx::ListBox->new( $panel, -1, [ 10, 10 ], [ 100, 200 ], [ "red", "green", "blue", 1 .. 8 ], wxLB_SINGLE ); use Wx::Event qw( EVT_LISTBOX ); EVT_LISTBOX( $self, $self->{lb1}, \&on_select ); $self->{lb2} = Wx::ListBox->new( $panel, -1, [ 120, 10 ], [ 100, 200 ], [ "10", "20", "30" ], wxLB_SINGLE ); use Wx qw' wxTE_READONLY wxTE_MULTILINE wxDefaultPosition wxDefa +ultSize '; $self->{logtext} = Wx::TextCtrl->new( $self, -1, "Welcome to wxPerl\n", wxDefaultPosition, [ 200, 100 ], wxTE_READONLY | wxTE_MULTILINE ); Wx::Log::SetActiveTarget( Wx::LogTextCtrl->new( $self->{logtext} ) + ); use Wx qw' wxVERTICAL wxEXPAND wxHORIZONTAL wxALL '; my ($topsizer) = Wx::BoxSizer->new(wxVERTICAL); my ($logsizer) = Wx::BoxSizer->new(wxHORIZONTAL); $topsizer->Add( $panel, 0, wxEXPAND ); $topsizer->AddSpacer(1); $logsizer->Add( $self->{logtext}, 1, wxALL | wxEXPAND, 0 ); $topsizer->Add( $logsizer, 1, wxEXPAND ); $self->SetSizer($topsizer); $self->Layout(); $topsizer->Fit($self); $topsizer->SetSizeHints($self); $self->{target} = MyTextTarget->new( $self->{lb2} ); return $self; } sub on_select { my ( $self, $event ) = @_; my $selection = $self->{lb1}->GetSelection(); my $text = $self->{lb1}->GetStringSelection(); carp( 'selected text ', $text ); my $text_obj = Wx::TextDataObject->new($text); my $source = Wx::DropSource->new( $self->{lb1} ); $source->SetData($text_obj); use Wx qw' wxDrag_AllowMove wxDrag_DefaultMove wxDragMove wxDragCo +py wxDragMove wxDragLink wxDragCancel wxDragNone '; my $drop_result = $source->DoDragDrop(wxDrag_DefaultMove); carp( 'drop_result(', $drop_result, ') ', 'wxDragCopy (', wxDragCopy, ') ', 'wxDragMove (', wxDragMove, ') ', 'wxDragLink (', wxDragLink, ') ', 'wxDragCancel (', wxDragCancel, ') ', 'wxDragNone (', wxDragNone, ') ' ); if ( $drop_result == wxDragMove ) { #the selection was moved-no +t copied carp( 'deleting ', $self->{lb1}->Delete($selection) ); } } package MyTextTarget; use Wx::Perl::Carp; use Wx::DND; use strict; use base qw( Wx::TextDropTarget ); sub new { my $class = shift; my $target_widget = shift; my $self = $class->SUPER::new(@_); $self->{target_widget} = $target_widget; $self->{target_widget}->SetDropTarget($self); $self->{text_obj} = Wx::TextDataObject->new($target_widget); $self->SetDataObject( $self->{text_obj} ); return $self; } sub OnDropText { carp("OnDropText @_ "); my ( $self, $x, $y, $d ) = @_; $self->GetData(); my $text = $self->{text_obj}->GetText(); my $c = $self->{target_widget}->GetCount(); carp( 'count ', $c ); $self->{target_widget}->InsertItems( [$text], $c ); return 1; # important } __END__

In reply to Re^3: WxPerl DnD by Anonymous Monk
in thread WxPerl DnD 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.