GTK2 - Perl learning record

xiaoxiao2021-03-05  25

There are two parameters when HBOX and VBOX are created:

NEW (whether the distance between each box, the distance between the internal widgets)

Window set internal interval:

SET_BORDER_WIDTH ($ PX)

Let Scroll to the bottom:

Use Glib QW (false); Use gtk2 -init; # create a window with a scrolled text view. my $ window = gtk2 :: window-> new; $ window-> signal_connect (delete_event => sub {eXit}); My $ scroll = gtk2 :: scrolledwindow-> new; my $ textView = gtk2 :: textview-> new; $ scroll-> add ($ textView); $ Window-> Add_all; $ Window-> show_all;

MY $ buffer = $ textView-> get_buffer;

# Create a mark at the end of the buffer, with right gravity, # so this you in insert text, the mark always stay # the right (at the end). MY $ END_MARK = $ buffer-> create_mark ('end " , $ buffer-> get_end_iter, FALSE);. # every time we insert text, scroll to that mark $ buffer-> signal_connect (insert_text => sub {$ textview-> scroll_to_mark ($ end_mark, 0.0, TRUE, 0.0, 1.0) ;});

# Display the Output of some long-running command ... Open in, "Sleep 1; LS -L |"; GLIB :: IO-> Add_watch (Fileno in, ['IN', 'Hup'], SUB {MY ($ FD, $ condition) = @_; if ($ condition> = 'in') {$ buffer-> INSERT ($ buffer-> get_end_iter, scalar);}} ($ condition> = 'hup') {close Return false;} return true;});

GTK2-> main; link: http://gtk2-perl.sourceforge.net/faq/#46

转载请注明原文地址:https://www.9cbs.com/read-39085.html

New Post(0)