deadpickle has asked for the wisdom of the Perl Monks concerning the following question:
I recieve the errors: *** Can't locate object method "set_text" via package "Gtk2::Button" at grruvibeta.pl line 117. *** ignoring at grruvibeta.pl line 24. The lines that the errors are located at are: $buffer->set_text( "testing the text box and it must be working"); and Gtk2->main;use Glib qw/TRUE FALSE/; use Gtk2 '-init'; use strict; use warnings; my $user = "uas"; my $server = "updraft.unl.edu"; my $uas_local = '/home/deadpickle/Desktop/Gtk2'; my $uas_remote = '/home/uas/Scripts/COORDS'; my $way_local = '/home/deadpickle/Desktop/Gtk2'; my $way_remote = '/home/uas/Scripts/WP'; #Main Window my $window = Gtk2::Window->new('toplevel'); $window->signal_connect(destroy => sub { Gtk2->main_quit; }); $window->set_border_width(3); $window->set_title("Virtual Cockpit Control Panel"); #Vbox setup and sub run my $vbox = &ret_vbox(); #add vbox $window->add( $vbox); $window->show; #Main loop Gtk2->main; #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #vbox sub ret_vbox { #create the vbox to pack everything into my $vbox = Gtk2::VBox->new( FALSE, 5); ############################### #Login info my $login_hbox = Gtk2::HBox->new( FALSE, 5); #Frame, Label and Entry my $login_frame = Gtk2::Frame->new("Login"); my $user_lbl = Gtk2::Label->new("User"); my $server_lbl = Gtk2::Label->new("Server"); my $user_eny = Gtk2::Entry->new; my $server_eny = Gtk2::Entry->new; #set entry text, width $user_eny->set_width_chars(5); $user_eny->set_text( $user); $server_eny->set_text( $server); #pack into hbox $login_hbox->pack_start( $user_lbl, FALSE, FALSE, 0); $login_hbox->pack_start( $user_eny, FALSE, FALSE, 0); $login_hbox->pack_start( $server_lbl, FALSE, FALSE, 0); $login_hbox->pack_start( $server_eny, FALSE, FALSE, 0); #add to frame $login_frame->add( $login_hbox); #pack it $vbox->pack_start($login_frame, FALSE, FALSE, 0); ############################### #uas info my $uas_hbox = Gtk2::HBox->new( FALSE, 5); #Frame, Label and Entry my $uas_frame = Gtk2::Frame->new("UAS"); my $uas_local_lbl = Gtk2::Label->new("Local"); my $uas_remote_lbl = Gtk2::Label->new("Remote"); my $uas_local_eny = Gtk2::Entry->new; my $uas_remote_eny = Gtk2::Entry->new; #set entry text $uas_local_eny->set_text( $uas_local); $uas_remote_eny->set_text( $uas_remote); #pack into hbox $uas_hbox->pack_start( $uas_local_lbl, FALSE, FALSE, 0); $uas_hbox->pack_start( $uas_local_eny, FALSE, FALSE, 0); $uas_hbox->pack_start( $uas_remote_lbl, FALSE, FALSE, 0); $uas_hbox->pack_start( $uas_remote_eny, FALSE, FALSE, 0); #add to frame $uas_frame->add( $uas_hbox); #pack it $vbox->pack_start($uas_frame, FALSE, FALSE, 0); ############################### #waypoint info my $way_hbox = Gtk2::HBox->new( FALSE, 5); #Frame, Label and Entry my $way_frame = Gtk2::Frame->new("Waypoints"); my $way_local_lbl = Gtk2::Label->new("Local"); my $way_remote_lbl = Gtk2::Label->new("Remote"); my $way_local_eny = Gtk2::Entry->new; my $way_remote_eny = Gtk2::Entry->new; #set entry text $way_local_eny->set_text( $way_local); $way_remote_eny->set_text( $way_remote); #pack into hbox $way_hbox->pack_start( $way_local_lbl, FALSE, FALSE, 0); $way_hbox->pack_start( $way_local_eny, FALSE, FALSE, 0); $way_hbox->pack_start( $way_remote_lbl, FALSE, FALSE, 0); $way_hbox->pack_start( $way_remote_eny, FALSE, FALSE, 0); #add to frame $way_frame->add( $way_hbox); #pack it $vbox->pack_start($way_frame, FALSE, FALSE, 0); ############################### #text box my $text = Gtk2::TextView->new; my $scroll = Gtk2::ScrolledWindow->new; $scroll->set_policy('automatic', 'automatic'); $scroll->add($text); my $buffer = $text->get_buffer; $text->set_editable(0); $vbox->pack_start($scroll, FALSE, FALSE, 0); ############################### #Connect info my $button = Gtk2::Button->new_with_mnemonic ("_Connect"); $button->signal_connect("clicked" => \&connect); $vbox->pack_start($button, FALSE, FALSE, 0); ############################### #Show all $vbox->show_all; return $vbox; } #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #Connect subroutine sub connect { my $buffer = shift; $buffer->set_text( "testing the text box and it must be workin +g"); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Gtk2 text widget
by quester (Vicar) on Jul 11, 2007 at 07:03 UTC | |
by deadpickle (Pilgrim) on Jul 11, 2007 at 20:06 UTC | |
|
Re: Gtk2 text widget
by zentara (Cardinal) on Jul 11, 2007 at 13:07 UTC |