From: Martin B. <mb...@ib...> - 2003-10-10 08:42:27
|
did anyone get a chance to look at this ? I built a gui with Glade, and inside "package My Frame" i had to add the "use Wx::Event" line. I added the EVENT's in here as well, as per the demo.pl program. I'd be interested to se if anyone else gets the event triggered twice, I find that when I click the combo_box_1 control, the "scrollme()" function is fired twice ?!? any ideas ? regards Martin #!/usr/bin/perl -w -- # generated by wxGlade 0.3.1 on Wed Oct 08 11:29:40 2003 # To get wxPerl visit http://wxPerl.sourceforge.net/ use Wx 0.15 qw[:allclasses]; use strict; package MyFrame; use Wx qw[:everything]; use Wx::Event qw(EVT_SIZE EVT_LISTBOX EVT_LISTBOX_DCLICK EVT_CHECKBOX EVT_MENU EVT_COMMAND_LEFT_CLICK EVT_BUTTON EVT_NOTEBOOK_PAGE_CHANGING EVT_NOTEBOOK_PAGE_CHANGED EVT_LIST_ITEM_SELECTED EVT_CHOICE EVT_COMBOBOX EVT_TEXT EVT_TEXT_ENTER EVT_RADIOBOX); use base qw(Wx::Frame); use strict; sub new { my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_; $parent = undef unless defined $parent; $id = -1 unless defined $id; $title = "" unless defined $title; $pos = wxDefaultPosition unless defined $pos; $size = wxDefaultSize unless defined $size; $name = "" unless defined $name; # begin wxGlade: MyFrame::new $style = wxDEFAULT_FRAME_STYLE unless defined $style; $self = $self->SUPER::new( $parent, $id, $title, $pos, $size, $style, $name ); # Menu Bar $self->{frame_1_menubar} = Wx::MenuBar->new(); $self->SetMenuBar($self->{frame_1_menubar}); my $wxglade_tmp_menu; $wxglade_tmp_menu = Wx::Menu->new(); $wxglade_tmp_menu->Append(Wx::NewId(), "Exit", ""); $self->{frame_1_menubar}->Append($wxglade_tmp_menu, "File"); # Menu Bar end $self->{label_1} = Wx::StaticText->new($self, -1, "French ", wxDefaultPosition, wxDefaultSize, ); $self->{combo_box_1} = Wx::ComboBox->new($self, -1, "", wxDefaultPosition, wxDefaultSize, ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""], wxCB_DROPDOWN); $self->{label_2} = Wx::StaticText->new($self, -1, "English ", wxDefaultPosition, wxDefaultSize, ); $self->{combo_box_2} = Wx::ComboBox->new($self, -1, "", wxDefaultPosition, wxDefaultSize, ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""], wxCB_DROPDOWN); $self->{button_4} = Wx::Button->new($self, -1, "button_4"); $self->{frame_1_statusbar} = $self->CreateStatusBar(1); $self->__set_properties(); $self->__do_layout(); EVT_BUTTON( $self, $self->{button_4} , \&DoIt ); EVT_COMBOBOX( $self, $self->{combo_box_1} , \&scrollme ); EVT_MENU($self, $self->{frame_1_menubar}, sub {print "You clicked exit\n";$_[0]->Close( 1 )}); return $self; # end wxGlade } sub scrollme { my( $this, $event ) = @_; #my $string = "event selection string is: ", $event->GetString(); #$string .= "control selection string is: '", $this->{combo_box_1}->GetStringSelection(); #$this->SetStatusText($string); print "scrollme selection ".$event->GetString()."\n"; $event->Skip(); #print "ID ".$event->GetInt()."\n"; #print "control ".$this->{combo_box_1}->GetStringSelection()."\n"; } sub DoIt { my( $this, $event ) = @_; $this->SetStatusText("You clicked on Button 4"); } sub __set_properties { my $self = shift; # begin wxGlade: MyFrame::__set_properties $self->SetTitle("frame_1"); $self->SetBackgroundColour(Wx::Colour->new(255, 255, 255)); $self->{label_1}->SetBackgroundColour(Wx::Colour->new(255, 255, 255)); $self->{label_1}->SetFont(Wx::Font->new(12, wxDEFAULT, wxNORMAL, wxNORMAL, 0, "")); $self->{combo_box_1}->SetSize(161, 21); $self->{combo_box_1}->SetSelection(-2147483648); $self->{label_2}->SetBackgroundColour(Wx::Colour->new(255, 255, 255)); $self->{label_2}->SetFont(Wx::Font->new(12, wxDEFAULT, wxNORMAL, wxNORMAL, 0, "")); $self->{combo_box_2}->SetSize(166, 161); $self->{combo_box_1}->Clear(); $self->{combo_box_1}->Append("$_") foreach (0..50); $self->{combo_box_2}->SetSelection(0); $self->{frame_1_statusbar}->SetStatusWidths(-1); my( @frame_1_statusbar_fields ) = ( "frame_1_statusbar" ); if( @frame_1_statusbar_fields ) { $self->{frame_1_statusbar}->SetStatusText($frame_1_statusbar_fields[$_], $_) for 0 .. $#frame_1_statusbar_fields ; } # end wxGlade } sub __do_layout { my $self = shift; # begin wxGlade: MyFrame::__do_layout $self->{sizer_5} = Wx::BoxSizer->new(wxVERTICAL); $self->{sizer_6} = Wx::BoxSizer->new(wxHORIZONTAL); $self->{sizer_6}->Add($self->{label_1}, 0, 0, 0); $self->{sizer_6}->Add($self->{combo_box_1}, 0, wxEXPAND, 0); $self->{sizer_6}->Add(80, 300, 0, wxEXPAND, 0); $self->{sizer_6}->Add($self->{label_2}, 0, 0, 0); $self->{sizer_6}->Add($self->{combo_box_2}, 0, 0, 0); $self->{sizer_5}->Add($self->{sizer_6}, 1, wxEXPAND, 0); $self->{sizer_5}->Add($self->{button_4}, 0, wxEXPAND, 0); $self->SetAutoLayout(1); $self->SetSizer($self->{sizer_5}); $self->{sizer_5}->Fit($self); $self->{sizer_5}->SetSizeHints($self); $self->Layout(); # end wxGlade } # end of class MyFrame 1; package MyApp; use base qw(Wx::App); use strict; sub OnInit { my( $self ) = shift; Wx::InitAllImageHandlers(); my $frame_1 = MyFrame->new(); $self->SetTopWindow($frame_1); $frame_1->Show(1); return 1; } # end of class MyApp package main; unless(caller){ my $app = MyApp->new(); $app->MainLoop(); } #!/usr/bin/perl -w -- # generated by wxGlade 0.3.1 on Wed Oct 08 11:29:40 2003 # To get wxPerl visit http://wxPerl.sourceforge.net/ use Wx 0.15 qw[:allclasses]; use strict; package MyFrame; use Wx qw[:everything]; use Wx::Event qw(EVT_SIZE EVT_LISTBOX EVT_LISTBOX_DCLICK EVT_CHECKBOX EVT_MENU EVT_COMMAND_LEFT_CLICK EVT_BUTTON EVT_NOTEBOOK_PAGE_CHANGING EVT_NOTEBOOK_PAGE_CHANGED EVT_LIST_ITEM_SELECTED EVT_CHOICE EVT_COMBOBOX EVT_TEXT EVT_TEXT_ENTER EVT_RADIOBOX); use base qw(Wx::Frame); use strict; sub new { my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_; $parent = undef unless defined $parent; $id = -1 unless defined $id; $title = "" unless defined $title; $pos = wxDefaultPosition unless defined $pos; $size = wxDefaultSize unless defined $size; $name = "" unless defined $name; # begin wxGlade: MyFrame::new $style = wxDEFAULT_FRAME_STYLE unless defined $style; $self = $self->SUPER::new( $parent, $id, $title, $pos, $size, $style, $name ); # Menu Bar $self->{frame_1_menubar} = Wx::MenuBar->new(); $self->SetMenuBar($self->{frame_1_menubar}); my $wxglade_tmp_menu; $wxglade_tmp_menu = Wx::Menu->new(); $wxglade_tmp_menu->Append(Wx::NewId(), "Exit", ""); $self->{frame_1_menubar}->Append($wxglade_tmp_menu, "File"); # Menu Bar end $self->{label_1} = Wx::StaticText->new($self, -1, "French ", wxDefaultPosition, wxDefaultSize, ); $self->{combo_box_1} = Wx::ComboBox->new($self, -1, "", wxDefaultPosition, wxDefaultSize, ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""], wxCB_DROPDOWN); $self->{label_2} = Wx::StaticText->new($self, -1, "English ", wxDefaultPosition, wxDefaultSize, ); $self->{combo_box_2} = Wx::ComboBox->new($self, -1, "", wxDefaultPosition, wxDefaultSize, ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""], wxCB_DROPDOWN); $self->{button_4} = Wx::Button->new($self, -1, "button_4"); $self->{frame_1_statusbar} = $self->CreateStatusBar(1); $self->__set_properties(); $self->__do_layout(); EVT_BUTTON( $self, $self->{button_4} , \&DoIt ); EVT_COMBOBOX( $self, $self->{combo_box_1} , \&scrollme ); EVT_MENU($self, $self->{frame_1_menubar}, sub {print "You clicked exit\n";$_[0]->Close( 1 )}); return $self; # end wxGlade } sub scrollme { my( $this, $event ) = @_; #my $string = "event selection string is: ", $event->GetString(); #$string .= "control selection string is: '", $this->{combo_box_1}->GetStringSelection(); #$this->SetStatusText($string); print "scrollme selection ".$event->GetString()."\n"; $event->Skip(); #print "ID ".$event->GetInt()."\n"; #print "control ".$this->{combo_box_1}->GetStringSelection()."\n"; } sub DoIt { my( $this, $event ) = @_; $this->SetStatusText("You clicked on Button 4"); } sub __set_properties { my $self = shift; # begin wxGlade: MyFrame::__set_properties $self->SetTitle("frame_1"); $self->SetBackgroundColour(Wx::Colour->new(255, 255, 255)); $self->{label_1}->SetBackgroundColour(Wx::Colour->new(255, 255, 255)); $self->{label_1}->SetFont(Wx::Font->new(12, wxDEFAULT, wxNORMAL, wxNORMAL, 0, "")); $self->{combo_box_1}->SetSize(161, 21); $self->{combo_box_1}->SetSelection(-2147483648); $self->{label_2}->SetBackgroundColour(Wx::Colour->new(255, 255, 255)); $self->{label_2}->SetFont(Wx::Font->new(12, wxDEFAULT, wxNORMAL, wxNORMAL, 0, "")); $self->{combo_box_2}->SetSize(166, 161); $self->{combo_box_1}->Clear(); $self->{combo_box_1}->Append("$_") foreach (0..50); $self->{combo_box_2}->SetSelection(0); $self->{frame_1_statusbar}->SetStatusWidths(-1); my( @frame_1_statusbar_fields ) = ( "frame_1_statusbar" ); if( @frame_1_statusbar_fields ) { $self->{frame_1_statusbar}->SetStatusText($frame_1_statusbar_fields[$_], $_) for 0 .. $#frame_1_statusbar_fields ; } # end wxGlade } sub __do_layout { my $self = shift; # begin wxGlade: MyFrame::__do_layout $self->{sizer_5} = Wx::BoxSizer->new(wxVERTICAL); $self->{sizer_6} = Wx::BoxSizer->new(wxHORIZONTAL); $self->{sizer_6}->Add($self->{label_1}, 0, 0, 0); $self->{sizer_6}->Add($self->{combo_box_1}, 0, wxEXPAND, 0); $self->{sizer_6}->Add(80, 300, 0, wxEXPAND, 0); $self->{sizer_6}->Add($self->{label_2}, 0, 0, 0); $self->{sizer_6}->Add($self->{combo_box_2}, 0, 0, 0); $self->{sizer_5}->Add($self->{sizer_6}, 1, wxEXPAND, 0); $self->{sizer_5}->Add($self->{button_4}, 0, wxEXPAND, 0); $self->SetAutoLayout(1); $self->SetSizer($self->{sizer_5}); $self->{sizer_5}->Fit($self); $self->{sizer_5}->SetSizeHints($self); $self->Layout(); # end wxGlade } # end of class MyFrame 1; package MyApp; use base qw(Wx::App); use strict; sub OnInit { my( $self ) = shift; Wx::InitAllImageHandlers(); my $frame_1 = MyFrame->new(); $self->SetTopWindow($frame_1); $frame_1->Show(1); return 1; } # end of class MyApp package main; unless(caller){ my $app = MyApp->new(); $app->MainLoop(); } ****************************************************************************** The information in this document, including any attachments or subsequent correspondence originating from this email address ("email"), is confidential and may be legally privileged. It is intended solely for the addressee. However, it may be intercepted by the system controller at Bankgesellschaft Berlin AG for the purposes of monitoring communications relevant to the system controller's business. Access to this email by anyone else is unauthorised. If you have received this email in error, please notify the Sender immediately by telephone. Please also delete this email from your computer. Any form of reproduction, dissemination, copying, disclosure, modification, distribution or publication of this email is prohibited without the prior consent of Bankgesellschaft Berlin AG. If you are not the intended recipient, any action taken or omitted to be taken in reliance of this email is strictly prohibited and may be unlawful. Bankgesellschaft Berlin AG accepts no liability for the consequences of any person acting, or refraining from action in reliance of this email ****************************************************************************** |