in reply to Re^6: WxPerl and drag and dropping files
in thread WxPerl and drag and dropping files

here you go, a working drag and drop implementation. thank you very much for your dedicated patience with me mr monk :) i can finally finish this little tool...
$frame->DragAcceptFiles(1); EVT_DROP_FILES( $frame, \&ondrop ); sub ondrop { my ($self, $this) = @_; Wx::DropFilesEvent::GetFiles($this); our $dropfile = $this->GetFiles(); extract($dropfile); # or i can assign a button to +do the subroutine :) #print "$dropfile"; <----prints the filepath/name }
once again thank you very much anonymous monk. Also, do you see anything wrong with using the our statement here? is there a better way of doing it?

See, the contents of the file will always be the same, but the filenames are usually different because of the methods used to obtain this data. and the reason i needed it to do drag and drop was because staticallly setting a filename in the open statement wouldnt have worked to well. i would have had to rename the file to that statically assigned filename for it to work. but now it works great so far :)

But dont get to comfortable because i will probably have more questions lol

Replies are listed 'Best First'.
Re^8: WxPerl and drag and dropping files
by Anonymous Monk on Jun 22, 2014 at 08:35 UTC

    Use meaningful variable names ($this is traditional for instance ... the docs can't guess what varname you're using)

    Don't use global variables, you already have $frame , the globalest of the global things of your GUI application and all you could need or want, use it for storage

    Invoke methods like methods not functions

    Like this

    $frame->DragAcceptFiles(1); EVT_DROP_FILES( $frame, \&ondrop ); EVT_BUTTON( $frame, $ButExtract, \&onExtract ); ## its like ## EVT_BUTTON( $parent, $child, \&callback ); ## EVT_BUTTON( $parent, $child->GetId, \&callback ); ... sub ondrop { my( $frame, $wxDropFilesEvent ) = @_; my @files = $wxDropFilesEvent->GetFiles; $frame->{you_chose_these_files} = \@files; ## extract( $files[0] ); ## or whatever } sub onExtract { my( $frame, $extractBut ) = @_; my( $firstFile ) = @{ $frame->{you_chose_these_files} }; extract( $firstFile ); ... }

    But dont get to comfortable because i will probably have more questions lol

    I'm standing right now, but my laptop isn't high enough, so neck/back a little more stiff than usual ... still better than unadjustable hard dining room chair ... I'm done buying furniture :)

Re^8: WxPerl and drag and dropping files
by james28909 (Deacon) on Jul 10, 2014 at 19:10 UTC
    im back, can you point me in the right direction of how i would also get the directory of said dropped file? let me be a little more specific. the program outputs to the root directory in which the gui program is in. if i make me a link in the taskbar for the program and run it, then just start dropping files, it still puts the output into the gui programsd directory and not the directory in which the dropped file came from.
    im also trying to figure out how to return the md5 from the subroutine to the listbox. ill make another thread later if i cant figure it out myself :)