I'm trying to get Gtk2::TextView to display a simple line of text when you hit the Connect button. I cant seem to see why it does not work. EDITED: I added the whole code here and some of the suggestions
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"); }
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;

In reply to Gtk2 text widget by deadpickle

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.