package MyFrame; use base 'Wx::Frame'; use Wx::Event qw(EVT_BUTTON EVT_COMBOBOX ); my $sth; my $tablename; my $sqlcommand; my @lessonnumber; my @lessonsimplename; my @lessontitle; my @startingpagenumber; my $nameargument; my $increment = 0; my $dbh = DBI->connect("dbi:mysql:*********", "root","*******") or die "Can't connect to MySQL database: $DBI::errstr\n"; $sqlcommand = "SELECT lessonstring, lesson_number, description, starting_pagenumber FROM lesson_titles"; $sth = $dbh->prepare ($sqlcommand) or die "Cannot perform SQL INSERT: $DBI::errstr\n"; $sth->execute( ) or die "Cannot perform execute\n"; for ( $increment = 1; $increment <= 132; $increment++ ) { ( $lessonsimplename [ $increment-1 ], $lessonnumber[ $increment-1 ], $lessontitle [ $increment-1 ], $startingpagenumber [ $increment-1 ] ) = $sth->fetchrow_array(); } $sth->finish; $dbh->disconnect or warn "Disconnect failed: $DBI::errstr\n"; #for ( $increment = 1; $increment <= 132; $increment++ ) { # print ($lessonsimplename [ $increment ].": ".$lessontitle [ $increment ]." p. ".$startingpagenumber [ $increment ]."\n"); #} sub new { my $ref = shift; my $self = $ref->SUPER::new( undef, # parent window -1, # ID -1 means any '********', # title &Wx::wxDefaultPosition, # default position [200, 200] # size ); my $panel = Wx::Panel->new( $self, # parent window -1, # ID ); my $button1 = Wx::Button->new( $panel, # parent window -1, # ID 'Click me 1!', # label [50, 20], # position &Wx::wxDefaultSize # default size ); my $button2 = Wx::Button->new( $panel, # parent window -1, # ID 'Click me 2!', # label [50, 50], # position &Wx::wxDefaultSize # default size ); my $button3 = Wx::Button->new( $panel, # parent window -1, # ID '*********', # label [50, 80], # position &Wx::wxDefaultSize # default size ); my $combobox1 = Wx::ComboBox->new( $panel, -1, $lessonsimplename[ 0 ], [50, 110], [-1, -1], \@lessonsimplename, 0, &Wx::wxDefaultValidator, '' ); EVT_BUTTON( $self, $button1, \&Button1Click ); EVT_BUTTON( $self, $button2, \&Button2Click ); EVT_BUTTON( $self, $button3, \&Button3Click ); EVT_COMBOBOX( $self, $combobox1, \&Combobox1action ); return $self; } sub Button1Click { my( $self, $event ) = @_; $self->SetTitle( 'Button 1 Clicked' ); } sub Button2Click { my( $self, $event ) = @_; $self->SetTitle( 'Button 2 Clicked' ); } sub Button3Click { my( $self, $event ) = @_; $self->SetTitle( '*********' ); } sub Combobox1action { my( $self, $event ) = @_; $self->SetTitle( 'Combo box selected' ); }