I have been doing a little studying but i am stuck on somethings, Events for one (or some events). I was able to get the button events down in no time it seemed, but now, I am having trouble dragging and dropping a file onto my gui. I want it to be able to accept any file from the top window, and I am having trouble with it and have spent about 20 hours on this and still havent figured it out (tho i am a little closer i think, hopefully LOL).
Another thing i am trying to figure out is how to share a variable from a subroutine and pass it to print in the listbox?
Anyway, here is my example code
use strict;
use warnings;
use Wx;
use Wx qw(:everything);
use Wx::Event qw(EVT_BUTTON);
use Wx::Event qw(EVT_DROP_FILES);
use File::Slurp;
use Digest::MD5;
######################################################################
+########
my $app = Wx::SimpleApp->new;
my $frame = Wx::Frame->new(undef,
-1,
'test tool',
wxDefaultPosition,
Wx::Size->new( 700, 400 ),
wxDEFAULT_DIALOG_STYLE | wxSTAY_ON_TOP
);
my $file = $_;
my ( $x, $y );
EVT_DROP_FILES( $x, $y );
tool($frame);
######################################################################
+#########
sub tool {
my ($self) = @_;
my $noteBook =
Wx::Notebook->new( $self, -1, wxDefaultPosition, wxDefaultSize )
+;
my $window1 = Wx::Panel->new( $noteBook, wxID_ANY );
my $window2 = Wx::Panel->new( $noteBook, wxID_ANY );
my $window3 = Wx::Panel->new( $noteBook, wxID_ANY );
$noteBook->AddPage( $window1, "First", 1, 0 );
$noteBook->AddPage( $window2, "Second", 0, 1 );
$noteBook->AddPage( $window3, "Third", 0, 2 );
my $button1 =Wx::Button->new( $window1, -1, "Test1", Wx::Point->ne
+w( 50, 300 ),wxDefaultSize );
EVT_BUTTON( $window1, $button1, \&test1 );
my $button2 = Wx::Button->new( $window1, -1, "Test2", Wx::Point->n
+ew( 175, 300 ),wxDefaultSize );
EVT_BUTTON( $window1, $button2, \&test2 );
my $lb1 = $window1->{my_listbox} =
Wx::ListBox->new( $window1, wxID_ANY, wxDefaultPosition,
Wx::Size->new( 300, 295 ) );
}
1;
$frame->Show(1);
$app->SetTopWindow($frame);
$app->MainLoop;
On line 19-21 it gives error "cant call connect on undefined value at Event.pm". I looked in Event.pm ofcourse i see "connect" at line 83, I try to make sense of it, but i am still somewhat to new to really understand what he has going on in there lol. Also if i try to put "$_" in EVT_DROP_FILES(line 21) I get "to many arguments for EVT_DROP_FILES".
the main thing is i still dont fully understand events and i am sure this is easy as pie, but i am probably just over thinking it as usual.
Any help would surely be appreciated :)
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.