SimpleGtk2

A Rapid Application Development Library for Gtk+ version 2.

Summary
SimpleGtk2A Rapid Application Development Library for Gtk+ version 2.
DescriptionSimpleGtk2 is a wrapper library to build graphical user interfaces with a minimal programming effort.
ExampleThe ‘Hello World’ example ;-)
BasicsShort introduction how SimpleGtk2 is constructed.
Special FeatureSimpleGtk2 has module support for FVWM to use it in conjunction with fvwm-perllib.
CaveatsThe problems and their handling.
BugsWhere to send bug reports.
LicenseThis software stands under the GPL V2 or higher.
Author© 2015 Thomas Funk t.f.nosp@m.unk@web.nosp@m..de
Thanks
HelpersHelper functions to support things like localization, stderr messages, etc.
Localization
use_gettextActivate localization via gettext.
translateTranslation function used to translate text parts interrupted by variables.
Messages
internal_dieInternal die function if a fatal error occurs.
show_errorPrint an error message to standard error.
show_messagePrint a message to standard error.
Support FunctionsCommon functions for signaling, object handling, etc.
Signaling
add_signal_handlerAdds a signal handler to a widget.
remove_signal_handlerRemoves a signal handler (signal-function pair) from a widget.
Object Handling
get_objectGet the SimpleGtk2 widget hash from internal objects list.
exist_objectCheck function if SimpleGtk2 object xyz exists.
Widget Handling
get_widgetGet a Gtk2 widget reference of a SimpleGtk2 object.
hide_widgetHide a widget.
show_widgetShow a hidden widget.
is_sensitiveReturns the sensitive state of a widget.
set_sensitiveSet sensitivity of a widget, a radio group or notebook page.
get_titleReturns the title text of a widget or the active value of a combo box.
set_titleSets the new title text of a widget or the active value of a combo box.
get_sizeReturns the current width and height (in pixel) of a widget.
set_sizeSets the new size of a widget.
get_posReturns the current position (in pixel) of a widget.
set_posSets the new position of a widget.
is_activeReturns the state of Check- and RadioButtons or for given combobox value/string.
is_underlinedReturns the state of a text whether it has an underline.
get_valueReturns a current value of a widget.
set_valueSets a new value for a widget.
set_valuesSet a bunch of new values for a widget.
Font Handling
get_fontsizeReturns the current font size of a widget.
get_fontfamilyReturns the current font family of a widget.
get_fontweightReturns the current font weight of a widget.
get_font_stringReturns the current font string of a widget.
get_font_arrayReturns current font string of a widget as an array.
font_array_to_stringConverts a font array into a font string.
font_string_to_arrayConverts a font string into a font array.
set_fontSet new font of a widget.
set_font_colorSet new font color of a widget.
Windows
GtkWindowToplevel window which can contain other widgets
new_windowCreates a new GtkWindow, a toplevel window, that contain other widgets.
showShow toplevel window with all widgets without running Gtk2->main
show_and_runShow toplevel window with all widgets and start Gtk2->main.
GtkMessageDialogA convenient message window
add_msg_dialogCreates a new GtkMessageDialog object.
show_msg_dialogShows a standalone, simple or normal message dialog.
Display Widgets
GtkImageA widget displaying an image.
add_imageCreates a new GtkImage widget.
get_imageReturns the image reference, the pixbuffer or the path.
set_imageSets a new image, stock icon, pixbuffer or file path.
GtkLabelA widget that displays a small to medium amount of text.
add_labelCreates a new GtkLabel widget.
GtkStatusbarReport messages of minor importance to the user.
add_statusbarCreates a new GtkStatusbar widget.
set_sb_textSets/display a new status bar message.
remove_sb_textRemoves a message from the status bar.
clear_sb_stackClears the message stack of a status bar.
Buttons and Toggles
GtkButtonA widget that creates a signal when clicked on.
add_buttonCreates a new GtkButton widget.
GtkCheckButtonA widget that creates a discrete toggle button with label.
add_check_buttonCreates a new GtkCheckButton widget.
GtkRadioButtonA choice from multiple check buttons.
add_radio_buttonCreates a new GtkRadioButton widget.
GtkLinkButtonA button bound to an URL.
add_link_buttonCreates a new GtkLinkButton widget.
Numeric/Text Data Entry
GtkEntryA single line text entry field.
add_entryCreates a new GtkEntry widget.
GtkSliderA horizontal or vertical slider widget for selecting a value from a range.
add_sliderCreates a new GtkSlider widget.
GtkSpinButtonRetrieve an integer or floating-point number from the user.
add_spin_buttonCreates a new GtkSpinButton widget.
Multiline Text Editor
GtkTextViewWidget that displays a GtkTextBuffer.
add_text_viewCreates a new GtkTextView widget.
get_textviewReturns the textview reference, its’ textbuffer or the file path.
set_textviewSets a new text, textbuffer or file path.
Tree and List Widgets
GtkTreeViewA widget for displaying both trees and lists.
add_treeviewCreates a new GtkTreeView widget.
get_treeviewReturns the treeview reference.
Combo Box and Menus
GtkComboBoxA widget used to choose from a list of items.
add_combo_boxCreates a new GtkComboBox widget.
GtkMenuBarA standard menu bar.
add_menu_barCreates a new GtkMenuBar widget.
GtkMenuA menu widget.
add_menuCreates a new GtkMenu widget.
GtkMenuItemThe widget used for item in menus.
add_menu_itemCreates a new GtkMenuItem widget.
Selectors (File/Font)
GtkFileChooserButtonA button to launch a file selection dialog.
add_filechooser_buttonCreates a new GtkFileChooserButton widget.
GtkFileChooserDialogA file chooser dialog.
add_filechooser_dialogCreates a new GtkFileChooserDialog widget.
show_filechooser_dialogShows a simple or normal filechooser dialog.
GtkFontButtonA button to launch a font selection dialog.
add_font_buttonCreates a new GtkFontButton widget.
GtkFontSelectionDialogA dialog box for selecting fonts.
add_fontselection_dialogCreates a new GtkFontSelectionDialog widget.
show_fontselection_dialogShows simple or normal fontselection dialog.
Layout Containers
GtkNotebookA tabbed notebook container.
add_notebookCreates a new GtkNotebook widget.
GtkNotebookPageA notebook page.
add_nb_pageCreates a new GtkNotebook page.
remove_nb_pageRemoves a notebook page from a notebook.
Ornaments
GtkFrameA bin with a decorative frame and optional label.
add_frameCreates a new GtkFrame widget.
GtkSeparatorA horizontal or vertical separator.
add_separatorCreates a new GtkSeparator widget.
Scrolling
GtkScrollBarA horizontal or vertical scrollbar.
add_scrollbarCreates a new GtkScrollBar widget.
Miscellaneous
GtkDrawingAreaA widget for custom user interface elements.
add_drawing_areaCreates a new GtkImage widget.
initial_drawBase function to draw with the drawing area.
GtkTooltipAdd tips to your widgets.
add_tooltipAdd a tooltip to a widget.
get_tooltipReturns the current tooltip text of a widget.
set_tooltipSets a new tooltip text on a widget.

Description

SimpleGtk2 is a wrapper library to build graphical user interfaces with a minimal programming effort.

It is based on the GtkFixed widget which is a container you can place child widgets at fixed positions and with fixed sizes, given in pixels.

Example

The ‘Hello World’ example ;-)

Original with Perl-Gtk2

#! /usr/bin/perl -w
use strict;
use Gtk2 -init;

# toplevel window
my $window = Gtk2::Window->new('toplevel');
$window->signal_connect(delete_event => sub { Gtk2->main_quit });

# button
my $button = Gtk2::Button->new('Action');
$button->signal_connect(clicked => sub{print("Hello Gtk2-Perl\n");});

# add button and show window
$window->add($button);
$window->show_all();

Gtk2->main;

With SimpleGtk2

#! /usr/bin/perl -w
use strict;
use SimpleGtk2;

# toplevel window
my $window = SimpleGtk2->new_window(Type => 'toplevel',
                                    Name => 'main',
                                    Title => 'Hello World');
$window->add_signal_handler('main', 'delete_event',
                                    sub { Gtk2->main_quit; });

# button
$window->add_button(Name => 'button', Pos => [20, 40],
                    Title => "Action", Sig => 'clicked',
                    Func => sub {print("Hello Gtk2-Perl\n");});
# show window
$window->show_and_run();

Basics

Short introduction how SimpleGtk2 is constructed.

SimpleGtk2 works with objects and containers.

All widget objects are stored as a hash in an internal object list hash in the respective window created with new_window.  Basically each object hash has the following structure:

object = (  type       => <string>  || undef,
            name       => <string>  || undef,
            title      => <string>  || undef,
            pos_x      => <integer> || undef,
            pos_y      => <integer> || undef,
            width      => <integer> || undef,
            height     => <integer> || undef,
            container  => <string>  || undef,
            tip        => <string>  || undef,
            handler    => <hash>    || {},
            ref        => <widget_reference> || undef
         )

Some widgets have additional entries like paths or other references but all of them can be accessed and updated with the support functions and shouldn’t used directly to prevent inconsistencies.

Containers are the window itself, frames or notebook pages.  If you are use a GUI designer like Qt-Designer (not a joke - Glade cannot be used because it handles the positioning and sizing without dimensions but Qt-Designer does) to create your surface you can take the position values one by one in SimpleGtk2.

SimpleGtk2 has implemented the most needed functions for each widget.  But if you need one which isn’t available you can use its Gtk reference and access it the old way.

Special Feature

SimpleGtk2 has module support for FVWM to use it in conjunction with fvwm-perllib.  See <FVWM Support> for more information.

Caveats

The problems and their handling.

GtkFixed has some caveats but the most annoying ones are removed or can be defanged with this library:

  • The GUI grows/shrinks automatically depending on the Font size.  Default is 10.  But you can create the GUI with your loved size.  Add it to your new_window definition and you’re fine.
  • The widget sizes aren’t changeable by themes because they’re defined by the user in the program.
  • Translation of text into other languages changes its size.  Also, display of non-English text will use a different font in many cases.  So keep in mind to use positioning and sizing sufficiently, that translations fit fine enough.

The only thing which still exists is that fixed widgets can’t properly be mirrored in right-to-left languages such as Hebrew and Arabic. i.e. normally GTK+ will flip the interface to put labels to the right of the thing they label, but it can’t do that with GtkFixed.  So your application will not be usable in right-to-left languages.

Bugs

Where to send bug reports.

Bug reports can be sent to fvwmnightshade-workers mailing list at https://groups.google.com/forum/?hl=en#!forum/fvwmnightshade-workers or submit them under https://github.com/Fvwm-Nightshade/Fvwm-Nightshade/issues.

License

This software stands under the GPL V2 or higher.

Author

© 2015 Thomas Funk t.f.nosp@m.unk@web.nosp@m..de

Thanks

Thanks to

  • The Perl-Gtk2 team helped me to fix some problems.
  • The Gtk2 team where I’ve borrowed some text passages and the arrangement.

Helpers

Helper functions to support things like localization, stderr messages, etc.

Localization

use_gettext

sub use_gettext #(<locale_paths>,
<translation_file>,
<codeset>)

Activate localization via gettext.

Parameters

<locale_paths>Colon separated list of locale paths to search for translations.
<translation_file>Name of the string translation file.
<codeset>Name of the used codeset translation file.

Returns

None.

Example

SimpleGtk2::use_gettext("fns-menu-configurator", "$ENV{FVWM_USERDIR}/locale:$ENV{FNS_SYSTEMDIR}/locale:+");

translate

sub translate #(<text>)

Translation function used to translate text parts interrupted by variables.

Parameters

<text>Text string to translate.

Returns

The translated text or its’ original.

Example

my $multi_menu_title = $win->translate('Menus in') . ' ' . $key;

Messages

internal_die

sub internal_die #(<msg>)

Internal die function if a fatal error occurs.

This may be used to end the program with a corresponding message.  For a clean exit use <showError> instead.

Parameters

<msg>Die message printed to stderr.

Returns

A die message before exiting the program.

Example

$win->internal_die($object, "No action defined!");

Output

[$win->$ExitButton]: No action defined! Exiting.

show_error

sub show_error #(<msg>)

Print an error message to standard error.

Parameters

<msg>Error message.

Returns

None.

Example

$win->show_error($nb_object, "No notebook page with number \"$number\" found.");

Output

[$win->$nb1][err]: No notebook page with number "123" found.

show_message

sub show_message #(<msg>)

Print a message to standard error.

Parameters

<msg>Message text.

Returns

None.

Example

$win->show_message("xcompmgr not installed. Ignoring.");

Output

[FNS-CompConfigurator][msg]: xcompmgr not installed. Ignoring.

Support Functions

Common functions for signaling, object handling, etc.

Signaling

add_signal_handler

sub add_signal_handler #(<name>,
<signal>,
<function>,
[<data>])

Adds a signal handler to a widget.

It connects a signal to a sub procedure related to the widget.

Parameters

<name>Name of the widget.  Must be unique.
<signal>Signal which will be “emitted” by the widget.  See Gtk2+ documentation for more info.
<function>Function to be executed if signal appears.
[<data>]Optional.  The data you wish to have passed to this function.

Returns

None.

Examples

$win->add_signal_handler('closeButton', 'clicked', sub{Gtk2->main_quit;});
--------------------------------------
$win->add_signal_handler('changeIconDir', 'clicked', \&change_path, [$win, 'entryIconDir']);

remove_signal_handler

sub remove_signal_handler #(<name>,
<signal>)

Removes a signal handler (signal-function pair) from a widget.

Parameters

<name>Name of the widget.  Must be unique.
<signal>Signal which should removed from the widget.

Returns

None.

Examples

$win->remove_signal_handler('closeButton', 'clicked');
--------------------------------------
$win->remove_signal_handler('changeIconDir', 'clicked');

Object Handling

get_object

sub get_object #(<name|widget>)

Get the SimpleGtk2 widget hash from internal objects list.

Parameters

<name>Name of a widget.  Must be unique.  OR
<widget>Reference object of a widget (e.g.  Gtk2::Button).

Returns

Object hash

Examples

# with name
$win->get_object('NB_page' . $number)->{pagelabel}->set_sensitive($state);
--------------------------------------
# with widget reference
my $object_name = $win->get_object($widget)->{name};

exist_object

sub exist_object #(<name|widget>)

Check function if SimpleGtk2 object xyz exists.

Parameters

<name>Name of a widget.  Must be unique.  OR
<widget>Gtk2 reference object of a widget (e.g.  Gtk2::Button).

Returns

1 if true else 0.

Example

if (defined($win->exist_object('entrySplashPath'))) { ... }

Widget Handling

get_widget

sub get_widget #(<name>)

Get a Gtk2 widget reference of a SimpleGtk2 object.

Restriction

Not available for the following widget: GtkNotebookPage.

Parameters

<name>Name of the widget.  Must be unique.

Returns

A Gtk2 widget reference.

Example

$win->add_signal_handler('checkEnabled' . $name_number, 'toggled', sub {&on_checkbox_enabled_toggled($win->get_widget('comboResolution' . $name_number), $name);});

hide_widget

sub hide_widget #(<name>)

Hide a widget.

Restriction

Not available for the following widgets: GtkMenu, GtkMenuItem, GtkMenuBar and GtkNotebookPage.

Parameters

<name>Name of the widget.  Must be unique.

Returns

None.

Example

$win->add_signal_handler('image1', 'button_press_event', sub{$win->hide_widget('frame1');});

show_widget

sub show_widget #(<name>)

Show a hidden widget.

Restriction

Not available for the following widgets: GtkMenu, GtkMenuItem, GtkMenuBar and GtkNotebookPage.

Parameters

<name>Name of the widget.  Must be unique.

Returns

None.

Example

$win->add_signal_handler('image1', 'button_press_event', sub{$win->show_widget('frame1');});

is_sensitive

sub is_sensitive #(<name>)

Returns the sensitive state of a widget.

Parameters

<name>Name of the widget.  Must be unique.

Returns

The sensitive state0 (inactive) or 1 (active).

Example

my $state = $win->is_sensitive('Check1');

set_sensitive

sub set_sensitive #(<name|group>,
<state>)

Set sensitivity of a widget, a radio group or notebook page.

Parameters

<name>Name of the widget.  Must be unique.  OR
<group>Name of the radio group.  Must be unique.
<state>New sensitivity state of the widget/radio group/notebook page.  0 (inactive) or 1 (active).

Returns

None.

Example

# deactivation of a radio group
$win->set_sensitive('r_state', 0);

get_title

sub get_title #(<name>)

Returns the title text of a widget or the active value of a combo box.

Restriction

Not available for the following widgets: GtkSlider, GtkScrollBar, GtkImage, GtkTextView, GtkMenuBar, GtkNotebook.

Parameters

<name>Name of the widget.  Must be unique.

Returns

The title text or undef.

Examples

# check whether a combo box value is currently set
unless ($win->get_title('comboWindow') eq 'TopLeft') {
    &set_config_value('WindowsPlacement', $win->get_title('comboWindow'));
}
--------------------------------------
# print window title with message to standard error
print STDERR "[" . $win->get_title($win->{name}) . "]: $user_cfg saved.\n";

set_title

sub set_title #(<name>,
<new_title>)

Sets the new title text of a widget or the active value of a combo box.

Restriction

Not available for the following widgets: GtkSlider, GtkScrollBar, GtkImage, GtkTextView, GtkMenuBar, GtkNotebook.

Parameters

<name>Name of the widget.  Must be unique.
<new_title>New title text for the widget or new active value for the combo box.

Returns

None.

Examples

# set label text depending on the current max virt size
$win->set_title('labelMaxSizeValue', $xrandr->getMaxVirtSize());
--------------------------------------
# set new title of the notebook page 2
$win->set_title("NB_page2", "1Bibbile");

get_size

sub get_size #(<name>)

Returns the current width and height (in pixel) of a widget.

Restriction

Not available for the following widgets: GtkMenu, GtkMenuItem, GtkNotebookPage.

Parameters

<name>Name of the widget.  Must be unique.

Returns

An array of the current width and height or undef.

Example

my ($width, $height) = $win->get_size('Image1');

set_size

sub set_size #(<name>,
<new_width>,
<new_height>)

Sets the new size of a widget.

Restriction

Not available for the following widgets: GtkCheckButton, GtkRadioButton, GtkLabel, GtkMenu, GtkMenuItem, GtkNotebookPage.

Parameters

<name>Name of the widget.  Must be unique.
<new_width>New width of the widget.
<new_height>New height of the widget.

Returns

None.

Example

$win->set_size('image1', 200, 100);

get_pos

sub get_pos #(<name>)

Returns the current position (in pixel) of a widget.

Restriction

Not available for the following widgets: GtkMenu, GtkMenuItem, GtkNotebookPage.

Parameters

<name>Name of the widget.  Must be unique.

Returns

An array of the current x and y position or undef.

Example

my ($pos_x, $pos_y) = $win->get_pos('cbox1');

set_pos

sub set_pos #(<name>,
<new_x>,
<new_y>)

Sets the new position of a widget.

Restriction

Not available for the following widgets: GtkMenu, GtkMenuItem, GtkNotebookPage.

Parameters

<name>Name of the widget.  Must be unique.
<new_x>New x-position of the widget.
<new_y>New y-position of the widget.

Returns

None.

Example

$win->set_pos('check_button', 10, 45);

is_active

sub is_active #(<name>,
[<value/string>])

Returns the state of Check- and RadioButtons or for given combobox value/string.

Parameters

<name>Name of the widget.  Must be unique.
<value/string>A given combobox value/string.

Returns

An array of the current x and y position or undef.

Example

my ($pos_x, $pos_y) = $win->get_pos('cbox1');

is_underlined

sub is_underlined #(<text>)

Returns the state of a text whether it has an underline.

Parameters

<text>Text to check.

Returns

1 for underlined else 0.

Example

if ($win->is_underlined($object->{title})) { ... }

get_value

sub get_value #( <name>,  
 <keyname>,  
or <keyname> = > <value>)

Returns a current value of a widget.

Parameters

<name>Name of a widget.
<keyname>Keyword of a value.  OR
<keyname> => <value>Nth value of the keyword array|hash.

KEYNAMES

GtkCheckButton

”Active”The current state of the check button.

GtkRadioButton

”Active”The current state of the radio button.
”Group”The current group object/reference.
”Groupname|Gname”The current group name (string).

GtkLinkButton

”Uri”The current uri of the link button.

GtkFontButton

”Fontstring”The current font string (family, size, weight) of the font button.
”Fontfamily”The current font family.
”Fontsize”The current font size.
”Fontweight”The current font weight.

GtkLabel

”Wrap|Wrapped”Returns whether lines in the label are automatically wrapped.
”Justify”The current justification of the label.

GtkEntry

”Align”The current alignment string of the entry.

GtkSpinButton

”Active”The current active value of the spin button.
”Align”The current alignment for the contents.
”Min|Minimum”The current minimum value.
”Max|Maximum”The current maximum value.
”Step”The current step increment.
”Snap”Returns whether the values are corrected to the nearest step.
”Rate|Climbrate”The current amount of acceleration that the spin button actually has.
”Digits”The current number of decimal places the value is displayed.

GtkComboBox

”Active”The current index of the active value.
”Data”The current data array of the combo box.
”Columns”The current number of columns to display.

GtkSlider

”Active”The current active value of the slider.
”Min|Minimum”The current minimum value.
”Max|Maximum”The current maximum value.
”Step”The current step increment.
”DrawValue”The current active value as a string.
”ValuePos|ValuePosition”The position in which the current value is displayed.
”Digits”The current number of decimal places the value is displayed.

GtkScrollbar

”Active”The current active value of the scrollbar.
”Min|Minimum”The current minimum value.
”Max|Maximum”The current maximum value.
”Step”The current step increment.
”Digits”The current number of decimal places the value is displayed.

GtkTextView

”LeftMargin”The current left margin size of paragraphs in the text view.
”RightMargin”The current right margin size of paragraphs.
”Wrap|Wrapped”The current wrap mode.
”Justify”The current justification.

Note: “Path”, “Textview” and “Textbuf|Textbuffer” can get with get_textview.

GtkMenu

”Justify”The current justification of the menu.

GtkMenuItem

”IconPath”The current path of the used icon on a standard menu item or undef.
”StockIcon”The current stock id of the used stock icon or undef.
”IconName”The current name of the used theme icon or undef.
”Icon”The current path/stock id/name of the used icon or undef.
”Active”The current state of a radio menu item.
”Group”The current group object/reference.
”Groupname|Gname”The current group name (string).

GtkNotebook

”Current|CurrentPage”The page number of the current page.
”Pages”The number of pages in the notebook.
”Popup”Returns 1 whether the popup is activated.  Else 0.
”No2Name|Number2Name”The page name with the page number.
”Scroll|Scrollable”Returns whether the tab label area has arrows for scrolling.
”Tabs”The edge at which the tabs are drawn or “none”.

GtkNotebookPage

”PageNumber”The page number of the notebook page.
”Notebook”The name of the notebook.

GtkFontButton

”fontstring”The string of the current font e.g “Arial Rounded MT Bold, Bold Italic 12”.
”fontfamily”The current font family (“Arial Rounded MT Bold”).
”fontsize”The current font size (“12”).
”fontweight”The current font weight (“Bold Italic”).

GtkFontSelectionDialog

”previewstring”The current preview text of the font selection dialog.
”fontstring”The current font string e.g “Arial Rounded MT Bold, Bold Italic 12”.
”fontfamily”The current font family (“Arial Rounded MT Bold”).
”fontsize”The current font size (“12”).
”fontweight”The current font weight (“Bold Italic”).

GtkStatusbar

”message”The text for the given message-id
”msgid”The message id for the given text.  If “last” is given the last message id.
”stackref”The stack reference.
”stackcount”The stack count.

GtkTreeView::List

”editable”Whether the in-place editing on column <index> is enabled (1).
”path”The path of row <index> (0 indexed) or the paths if an index array is given.
”cell”The value of a cell given as an array with [<row_index>, <column_index>] 0 indexed.

GtkTreeView::Tree

”iter”The iter of the current selected element.
”path”The path of the current selected element.
”row”The row values as an array of the given iter.

Returns

The found value.

Examples

if ($win->get_value("comboMaxFreq" . $a, "active") != $win->get_value("comboMaxFreqCommon", "active")) { ... }
--------------------------------------
my $rowref = $window->get_value("slist", path => $index);

set_value

sub set_value #(<name>,  
<keyname> = > <new_value>)

Sets a new value for a widget.

Parameters

<name>Name of a widget.
<keyname> => <new_value>Keyword of a value and its new value.

KEYNAMES

GtkCheckButton

Active => <0/1>The new state of the check button.  0 (deactivated) or 1 (activated).

GtkRadioButton

Active => <0/1>The new state of the radio button.  0 (deactivated) or 1 (activated).

GtkLinkButton

Uri => <uri-text>The new uri of the link button.

GtkFontButton

Fontstring => <font-string>The new font string (family, size, weight) of the font button.
Fontfamily => <fontfamily>The new font family.
Fontsize => <fontsize>The new font size.
Fontweight => <fontweight>The new font weight.

GtkLabel

Wrap|Wrapped => <0/1>The new wrapping of the text.  0 (off) or 1 (on).
Justify => <justification>The new justification of the text: left, right, center or fill,

GtkEntry

Align => <xalign>The new alignment of the entry: left or right.

GtkSpinButton

Start => <start_value>The new start value of the spin button.
Active => <active_value>The new active value.
Min|Minimum => <min_value>The new minimum value.
Max|Maximum => <max_value>The new maximum value.
Step => <step_value>The new step increment.
Snap => <0/1>Sets the new policy as to whether values are corrected to the nearest step increment when an invalid value is provided.
Rate|Climbrate => <climb_rate>The new amount of acceleration that the spin button shall has.
Digits => <used_digits>The new number of decimal places the value will be displayed.

GtkComboBox

Active => <active_index>The active item of the combo box to be the item at index.
Data => [<Array_of_values>]The new array of values/strings being displayed in the combo box.
Columns => <wrap_to_x_columns>The current number of columns to display.

GtkSlider

Start => <start_value>The new start value of the slider.
Active => <active_value>The new active value.
Min|Minimum => <min_value>The new minimum value.
Max|Maximum => <max_value>The new maximum value.
Step => <step_value>The new step increment.
DrawValue => <0/1>Specifies whether the current value is displayed as a string next to the slider.
ValuePos|ValuePosition => <value_position>The new position where the current value will be displayed.
Digits => <used_digits>The new number of decimal places the value will be displayed.

GtkScrollbar

Start => <start_value>The new start value of the scrollbar.
Active => <active_value>The new active value.
Min|Minimum => <min_value>The new minimum value.
Max|Maximum => <max_value>The new maximum value.
Step => <step_value>The new step increment.
Digits => <used_digits>The new number of decimal places the value will be displayed.

GtkTextView

LeftMargin => <in_pixel>The new left margin size of paragraphs in the text view.
RightMargin => <in_pixel>The new right margin size of paragraphs.
Wrap|Wrapped => <wrap_mode>The new wrap mode.
Justify => <justification>The new justification.

Note: ‘Path’, ‘Textview’ and ‘Textbuf|Textbuffer’ can set with set_textview.

GtkMenu

Justify => <justification>The new justification of the menu.

GtkMenuItem

Icon => <path|stock|name>The new path of an icon or its’ stock id (‘Stock’) or its’ icon name (‘Name’) on a standard menu item.
Active => <0/1>The new state of a radio menu item.

GtkNotebook

Current|CurrentPage => <page_number|next|prev>The new current page.  Possible values: <page_number>, ‘Next’ or ‘Prev’.
Popup => <0/1>Enables (1) or disables (0) the popup menu.
Scroll|Scrollable => <0/1>Sets whether the tab label area will have arrows for scrolling.
Tabs => <edges>The edge at which the tabs are drawn.

GtkNotebookPage

Reorder => <0/1>Sets the notebook page to a new position.

GtkFontButton

fontstring => <font_string>The new used font as string.  Font family and size are required.
fontfamily => <font_family>The new font family.
fontsize => <font_size>The new font size.
fontweight => <font_weight>The new font weight.

GtkFontSelectionDialog

previewstring => <preview_text>The new preview text of the font selection dialog.
fontstring => <font_string>The new used font as string.  Font family and size are required.
fontfamily => <font_family>The new font family.
fontsize => <font_size>The new font size.
fontweight => <font_weight>The new font weight.

GtkTreeview::List

mode => <selection_mode>The new selection mode.  Possible values are: ‘none’, ‘single’ (default), ‘browse’ and ‘multiple’.
sortable => <0/1>Set the current column sortable (1) or not (0 - default).
reordable => <0/1>Set the rows reordable (1) or not (0 - default).
select => <row|[row_list]>Select row(s) in the list by index.  If the list is set for multiple selection, all indices in the list will be set/unset; otherwise, just the first is used.  If the list is set for no selection, then nothing happens.
unselect => <row|[row_list]>Unselect row(s) in the list by index.

GtkTreeview::Tree

mode => <selection_mode>The new selection mode.  Possible values are: ‘none’, ‘single’ (default), ‘browse’ and ‘multiple’.
sortable => <0/1>Set the current column sortable (1) or not (0 - default).
reordable => <0/1>Set the rows reordable (1) or not (0 - default).
iter => <iter>The iter of the current selected element.
path => <path_object>The path object of the current selected element.
row => [row_values]The new row values as an array of the given iter.

Returns

None.

Examples

$win->set_value('NB1', Currentpage => $win->get_value('NB1', Title2number => $out));
--------------------------------------
$spin_button->set_value($cell->get("value"));

set_values

sub set_values #(<name>,  
<keyname> = > <new_value>,
<keyname> = > <new_value>,
...  )

Set a bunch of new values for a widget.

Parameters

<name>Name of a widget.
<keyname>Keyword of a value and its new value.

KEYNAMES

See set_value for possible keynames.

Returns

None.

Examples

$win->set_values('spinDesktopX', Start => $current_x_desks, Min => 1, Max => $max, Step => 1);
--------------------------------------
$win->set_values($name, Data => $item_list_ref, Start => $active_item_nr);

Font Handling

get_fontsize

sub get_fontsize #(<name|widget>)

Returns the current font size of a widget.

Parameters

<name>Name of the widget.  Must be unique.  OR
<widget>Gtk2 reference object of a widget (e.g.  Gtk2::Button).

Returns

The font size.

Example

my $fontsize = get_fontsize($window);

get_fontfamily

sub get_fontfamily #(<name|widget>)

Returns the current font family of a widget.

Parameters

<name>Name of the widget.  Must be unique.  OR
<widget>Gtk2 reference object of a widget (e.g.  Gtk2::Button).

Returns

The font family.

Example

my $fontsize = get_fontsize($window);

get_fontweight

sub get_fontweight #(<name|widget>)

Returns the current font weight of a widget.

Parameters

<name>Name of the widget.  Must be unique.  OR
<widget>Gtk2 reference object of a widget (e.g.  Gtk2::Button).

Returns

The font weight.

Example

my $fontweight = get_fontweight($window);

get_font_string

sub get_font_string #(<name>)

Returns the current font string of a widget.

Parameters

<name>Name of the widget.  Must be unique.

Returns

The font size.

Example

$testfont = $win->get_font_string('frame1');

get_font_array

sub get_font_array #(<name>)

Returns current font string of a widget as an array.

Parameters

<name>Name of the widget.  Must be unique.

Returns

A font array [family, size, weight].

Example

my @fontarray = $win->get_font_array('frame1');

font_array_to_string

sub font_array_to_string #(<font_array>)

Converts a font array into a font string.

Parameters

<font_array>Font as an array like [family, size[, weight]].  Font family AND size is required.

Returns

A font string.

Example

my @fontarray = (Sans, 12);
my $fontstring = font_array_to_string(@fontarray);

font_string_to_array

sub font_string_to_array #(<font_string>)

Converts a font string into a font array.

Parameters

<font_string>Font string.  Font family AND size is required.

Returns

A font array [family, size[, weight]].

Example

my @fontarray = font_string_to_array('Arial Rounded MT Bold, Bold Italic 12');

set_font

sub set_font #( <name>,  
 <font_string>,  
or [family, size, [weight]],  
or Family = > <Family>,
 Size = > <Size>,
 Weight = > <Weight>)

Set new font of a widget.

Parameters

<name>Name of the widget.  Must be unique.
<font_string>Font string.  Font family AND size is required.  OR
<font_array>Font as an array: [family, size, [weight]].  Font family AND size is required.  OR
<Family>Font family.
<Size>Font size.
<Weight>Font weight.

Returns

None.

Example

$win->set_font('frame1', Family => 'Bernard MT Condensed');

set_font_color

sub set_font_color #(<name>,
<color>,
[<state>])

Set new font color of a widget.

Parameters

<name>Name of the widget.  Must be unique.
<color>Font color.  Can be a X11 color name or hexadecimal value.  See more at ’Table of Color’
[<state>]Optional.  Widget state.  Default is ‘normal’.  For more see Gtk2-Perl StateType

Returns

None.

Examples

$win->set_font_color('checkButton1','red');
--------------------------------------
$win->set_font_color('label1', '#8B008B');

Windows

GtkWindow

Toplevel window which can contain other widgets

new_window

sub new_window #(Name = > <name>,
Title = > <window title>,
[Version => <version-string>],  
[Base => <font_size>],  
[Size => [width, height]],  
[Fixed => <0/1>],  
[Iconpath => <icon_path>],  
[ThemeIcon => <theme_icon_name>],  
[Statusbar => <show_time|1>]  )

Creates a new GtkWindow, a toplevel window, that contain other widgets.

It contains by default a fixed container in a scrollable window widget.  So whether it is resized smaller than defined vertical and/or horizontal scrollbars appear.

Parameters

Name => <name>Name of the window object.  Must be unique.
Title => <window title>Title of the window (displayed in the title bar).
[Version => version-string]Optional.  Version string of the program.  Will be appended after the title.
[Base => <font_size>]Optional.  This is the font size used while creating the layout.  Default is 10.
[Size => [width, height]]Optional.  Width and height of the window.
[Fixed => <0/1>]Optional.  Default: 0 (resizable).
[Iconpath => <icon_path>]Optional.  Path to an icon shown in title bar or on iconify.
[ThemeIcon => <theme_icon_name>]Optional.  Icon name from current theme.
[Statusbar => <show_time|1>]Optional.  If set a statusbar is shown at the bottom of the window.  <show_time> is the time in milliseconds the message will show or 1 if no <show_time> is wanted.

Returns

The main window object.

Example

my $win = SimpleGtk2->new_window(Name => 'mainWindow',
                        Title      => 'testem-all',
                        Size       => [400, 400],
                        ThemeIcon  => 'emblem-dropbox-syncing');

References

Gtk2-Perl, Gtk2

Available Support Function

show ()

show_and_run ()

show

sub show #()

Show toplevel window with all widgets without running Gtk2->main

This is the default loop function if library will be used in FVWM modules.

Parameters

None.

Returns

None.

show_and_run

sub show_and_run #()

Show toplevel window with all widgets and start Gtk2->main.

This is the default loop function.

Parameters

None.

Returns

None.

GtkMessageDialog

A convenient message window

add_msg_dialog

sub add_msg_dialog #(Name = > <name>,
Modal = > <0/1>,
DType = > <dialog_type>,
MTyp = > <message_type>,
[Icon => <path|stock|name>],  
[RFunc => <response_function>]  )

Creates a new GtkMessageDialog object.

GtkMessageDialog presents a dialog with an image representing the type of message (Error, Question, etc.) alongside some message text.

Internal Name Type

MessageDialog

Parameters

Name => <name>Name of the message dialog.  Must be unique.
Modal => <0/1>Behaviour of the message dialog.  Default: modal (1).  Else nonmodal (0).
DType => <dialog_type>Type of the message dialog.  Default: ‘none’.  Else ‘ok’, ‘close’, ‘cancel’, ‘yes-no’ or ‘ok-cancel’.
MTyp => <message_type>Type of the message.  Possible values: ‘info’, ‘warning’, ‘question’, ‘error’ or ‘other’.
[Icon => <path|stock|name>]Optional.  The used Icon beside of the main message.  Can be an icon file path, a stock icon or an icon name.
[RFunc => <response_function>]Optional.  Have to be set if nonmodal (Modal => 0) is chosen.  Gets the response ‘ok’, ‘close’, ‘cancel’, ‘yes’ or ‘no’.

Returns

None.

Examples

# a modal message dialog
$win->add_msg_dialog(Name => 'diag1',
        DType   => 'ok-cancel',
        MType   => 'warning',
        Icon    => 'gtk-quit');
--------------------------------------
# a non modal message dialog
$win->add_msg_dialog(Name => 'diag2',
        DType   => 'yes-no',
        MType   => 'info',
        RFunc   => \&nonModal,
        Modal   => 0);

References

Gtk2-Perl, Gtk2

Available Support Function

show_msg_dialog (<name>, “<message_text1>”, “<message_text2>”)A normal one.
show_msg_dialog (<dialog_type>, <message_type>, “<message_text>”)A standalone or simple one.

show_msg_dialog

sub show_msg_dialog #( <name>,
 <message_text1>,
 <message_text2>,
or <dialog_type>,
 <message_type>,
 <message_text>)

Shows a standalone, simple or normal message dialog.

The normal message dialog needs a message dialog object created with add_msg_dialog.

The standalone and the simple message dialog don’t need this object.

Parameters for a normal

<name>Name of the message dialog.  Must be unique.
<message_text1>The main message text.
[<message_text2>]Optional.  A second text

Parameters for a standalone or simple

<dialog_type>Type of the message dialog.  Default: ‘none’.  Else ‘ok’, ‘close’, ‘cancel’, ‘yes-no’ or ‘ok-cancel’.
<message_type>Type of the message.  Possible values: ‘info’, ‘warning’, ‘question’, ‘error’ or ‘other’.
<message_text>The main message text.

Returns

The response.  Can be “ok”, “close”, “cancel”, “yes”, “no” depending on the dialog type.

Examples

# A standalone message dialog
my $response = SimpleGtk2::show_msg_dialog('warning', 'yes-no', "This is a simple standalone");
--------------------------------------
# A simple one
my $response = $win->show_msg_dialog('warning', 'yes-no', "This is a simple one");
--------------------------------------
# A normal non-modal message dialog

sub nonModal{
    my $response = shift;
    if ($response eq 'yes') {print "Yes\n";}
    else {print "No\n";}
}

my $FirstMsg = "<span foreground=\"blue\" size=\"x-large\">Message Type</span>";
my $SecondMsg = "<span foreground='red' size=\"small\" style ='italic'>Info box.</span>";

$win->add_button(Name => 'Button2',
        Pos     => [60, 60],
        Size    => [80, 40],
        Title   => "_NonModal");
$win->add_signal_handler('Button2', 'clicked', sub{$win->show_msg_dialog('diag2', $FirstMsg, $SecondMsg);});

$win->add_msg_dialog(Name => 'diag2',
        DType   => 'yes-no',
        MType   => 'info',
        RFunc   => \&nonModal,
        Modal   => 0);

Display Widgets

GtkImage

A widget displaying an image.

add_image

sub add_image #( Name = > <name>,
 Path = > <file_path>,
or Pixbuffer = > <pix_buffer_object>,
or Stock = > [<stock_name>[,<stock_size>]],
 Size = > [width, height],
 Position = > [pos_x, pos_y],
 [Frame => <frame_name>],  
 [Tooltip => <tooltip_text>],  
 [Function => <function_click>],  
 [Signal => <signal>],  
 [Sensitive => <sensitive>]  )

Creates a new GtkImage widget.

The GtkImage widget displays an image.  Various kinds of object can be displayed as an image; most typically, you would load a GdkPixbuf (“pixel buffer”) from a file, and then display that.  Additionally it is possible to bind a left click action to the image.  Also a tooltip is possible.

Internal Name Type

Image

Parameters

Name => <name>Name of the image.  Must be unique.
Path => <file_path>Path of a picture to show.  OR
Pixbuf|Pixbuffer => <pix_buffer_object>Pixbuffer object (see Gtk2-Perl or Gdk2) of an image to show.  OR
Stock => [<stock_name>[,<stock_size>]]Stock icon to show.  <stock_size> is per default ‘dialog’ because for scaling.  So, if <stock_size> is given, Size is optional.
Size => [width, height]Width and height of the image.  It will be scaled if bigger/smaller.
Pos|Position => [pos_x, pos_y]Position of the image.
[Frame => <frame_name>]Optional.  Name of the frame if the image is located in one.  Must be unique.  See add_frame.
[Tip|Tooltip => <tooltip_text>]Optional.  Text of the tooltip shown while hovering over the image.
[Func|Function => <function_click>]Optional.  Function reference/sub.  Can be set later with add_signal_handlerNote: If data is used it have to be set as an array.
[Sig|Signal => <signal>]Optional.  The used action signal.  Only in conjunction with Func|Function.  Most used is ‘button_press_event’.
[Sens|Sensitive => <sensitive>]Optional.  Sets the image active/inactive.  Default: 1 (active).

Returns

None.

Example

# with pixbuf object
my $pixbuf = Gtk2::Gdk::Pixbuf->new_from_file("./myimage.png");
$win->add_image(Name => 'image2',
        Pos     => [240, 100],
        Size    => [50, 50],
        Tip     => 'A second picture',
        Frame   => 'frame1',
        Pixbuf  => $pixbuf);
$win->add_signal_handler('image2', 'button_press_event', \&Maximize);

References

Gtk2-Perl, Gtk2

Available Support Functions

image_reference = get_image (<name>, [<keyname>])

set_image (Name => <name>, Path => <file_path> or Pixbuffer => <pix_buffer_object> or Image => <image_object> or Stock => [<stock_name>, <stock_size>])

string = get_value (<name>, “Justify” or “Wrap|Wrapped”)

set_value (<name>, Justify|Wrap|Wrapped => <new_value>)

hide_widget (<name>)

show_widget (<name>)

(width, height) = get_size (<name>)

set_size (<name>, <new_width>, <new_height>)

(x_pos, y_pos) = get_pos (<name>)

set_pos (<name>, <new_x>, <new_y>)

state = is_sensitive (<name>)

set_sensitive (<name>, <state>)

string = get_tooltip (<name>)

set_tooltip (<name>, <tooltip_text>)

get_image

sub get_image #(<name>,
[<keyname>])

Returns the image reference, the pixbuffer or the path.  If no key is given the current Gtk2::Image reference will be returned.  Else an object or path depending to the key.

Parameters

<name>Name of the image.  Must be unique.
<keyname>Optional.  Possible keynames are: ‘Path’, ‘Image’ or ‘Pixbuf|Pixbuffer’.

Returns

The image reference, the pixbuffer or the path.

Examples

# get the pixbuffer
my $pixbuff = $win->get_image('Image1', 'Pixbuf');
--------------------------------------
# get path of the picture
my $file_path = $win->get_image('Image1', 'Image');

set_image

sub set_image #( Name = > <name>,
 Path = > <file_path>,
or Pixbuffer = > <pix_buffer_object>,
or Image = > <image_object>,
or Stock = > [<stock_name>, <stock_size>])

Sets a new image, stock icon, pixbuffer or file path.

Parameters

Name => <name>Name of the image.  Must be unique.
Path => <image_path>Path of the new image.  OR
Pixbuf|Pixbuffer => <pix_buffer_object>A Gtk2::Gdk::Pixbuf object of a new image.  OR
Image => <image_object>A Gtk2::Image object of a new image.  OR
Stock => [<stock_name>,<stock_size>]A Gtk2::Stock icon as a new image.  <stock_size> is per default ‘dialog’ because for scaling.  Note: If <stock_size> is given, width and height of the image will be changed.

Returns

None.

Example

# set a new image by path
$win->set_image('Image1', Path => '/usr/share/icons/gnome/256x256/actions/appointment-new');

GtkLabel

A widget that displays a small to medium amount of text.

add_label

sub add_label #(Name = > <name>,
Position = > [pos_x, pos_y],
Title = > <title>,
[Frame => <frame_name>],  
[Font => [family, size, weight]],  
[Widget => <name_of_linked_widget>],  
[Justify => <justify>],  
[Wrapped => <0/1>],  
[Tooltip => <tooltip_text>],  
[Sensitive => <sensitive>]  )

Creates a new GtkLabel widget.

The GtkLabel widget displays a small amount of text.  As the name implies, most labels are used to label another widget such as a GtkButton or a GtkMenuItem.

Internal Name Type

Label

Parameters

Name => <name>Name of the label.  Must be unique.
Pos|Position => [pos_x, pos_y]Position of the label.
Title => <title>Text of the label.
[Frame => <frame_name>]Optional.  Name of the frame if the label is located in one.  Must be unique.  See add_frame.
[Font => [family, size, weight]]Optional.  Sets the initial font.  Font family and size are required if set.
[Widget => <name_of_linked_widget>]Optional.  Links the text with a widget - in conjunction with underlined.
[Justify => <justify>]Optional.  Justification of the text.  Possible values: left, right, center, fill
[Wrap|Wrapped => <0/1>]Optional.  Wraps the text.  Only usable in a frame.
[Tip|Tooltip => <tooltip_text>]Optional.  Text of the tooltip shown while hovering over the label.
[Sens|Sensitive => <sensitive>]Optional.  Sets the label active/inactive.  Default: 1 (active).

Returns

None.

Example

$win->add_label(Name => 'label1',
        Pos     => [10, 20],
        Title   => "A Label.\n"."A new line",
        Justify => 'left');

References

Gtk2-Perl, Gtk2

Available Support Functions

string = get_value (<name>, “Justify” or “Wrap|Wrapped”)

set_value (<name>, Justify|Wrap|Wrapped => <new_value>)

hide_widget (<name>)

show_widget (<name>)

(x_pos, y_pos) = get_pos (<name>)

set_pos (<name>, <new_x>, <new_y>)

state = is_sensitive (<name>)

set_sensitive (<name>, <state>)

string = get_title (<name>)

set_title (<name>, <text>)

string = get_tooltip (<name>)

set_tooltip (<name>, <tooltip_text>)

GtkStatusbar

Report messages of minor importance to the user.

add_statusbar

sub add_statusbar #(Name = > <name>,
Position = > [pos_x, pos_y],
[Size => [width, height]],  
[Frame => <frame_name>],  
[Timeout => <show_time>],  
[Sensitive => <sensitive>]  )

Creates a new GtkStatusbar widget.

A GtkStatusbar is usually placed along the bottom of an application’s main GtkWindow.

It may provide a regular commentary of the application’s status, or may be used to simply output a message when the status changes.

Internal Name Type

Statusbar

Parameters

Name => <name>Name of the status bar.  Must be unique.
Pos|Position => [pos_x, pos_y]Position of the status bar.
[Size => [width, height]]Optional.  Size of the status bar.  Default is the complete window width.
[Frame => <frame_name>]Optional.  Name of the frame if the status bar is located in one.  Must be unique.  See add_frame.
[Timeout => <show_time>]Optional.  The time in milliseconds the message will be shown.  Default is 1 (no timeout).
[Sens|Sensitive => <sensitive>]Optional.  Sets the status bar active/inactive.  Default: 1 (active).

Returns

None.

Example

$win->add_statusbar(Name => 'sbar1',
        Pos     => [0, 0],
        Timeout => 2000);

Note

The main window supports a statusbar at the bottom, too.  See new_window for more details.

References

Gtk2-Perl, Gtk2

Available Support Functions

set_sb_text ([<name>], <text>)

remove_sb_text ([<name>], [<text>|<msg-id>])

clear_sb_stack (<name>)

string = get_value (<name>, “message” or “msgid” or “stackref” or “stackcount”)

set_value (<name>, message|msgid|stackref|stackcount => <new_value>)

hide_widget (<name>)

show_widget (<name>)

(x_pos, y_pos) = get_pos (<name>)

set_pos (<name>, <new_x>, <new_y>)

state = is_sensitive (<name>)

set_sensitive (<name>, <state>)

set_sb_text

sub set_sb_text #([<name>],
<text>)

Sets/display a new status bar message.

Parameters

<name>Optional.  Name of the status bar.  Must be unique.  If not set the main window status bar will be used.
<text>New text message for the status bar.

Returns

Message id.

Example

$win->set_sb_text('sbar1', $text);

remove_sb_text

sub remove_sb_text #([<name>],
[<text>|<msg-id>])

Removes a message from the status bar.

Parameters

<name>Optional.  Name of the status bar.  Must be unique.  If not set the main window status bar will be used.
<text|msg-id>Optional.  The id or its’ text message.  If not set the last message will be removed.

Returns

None.

Example

$win->remove_sb_text('sbar1', $msg_id[3]);

clear_sb_stack

sub clear_sb_stack #(<name>)

Clears the message stack of a status bar.

Parameters

<name>Name of the status bar.  Must be unique.  If not set the main window status bar will be used.

Returns

None.

Example

$win->clear_sb_stack();

Buttons and Toggles

GtkButton

A widget that creates a signal when clicked on.

add_button

sub add_button #(Name = > <name>,
Position = > [pos_x, pos_y],
Title = > <title>,
[Frame => <frame_name>],  
[Font => [family, size, weight]],  
[Color => [<color>, <state>]],  
[Size => [width, height]],  
[Tooltip => <tooltip_text>],  
[Function => <function_click>],  
[Signal => <signal>],  
[Sensitive => <sensitive>]  )

Creates a new GtkButton widget.

The GtkButton widget is generally used to attach a function to that is called when the button is pressed.

Internal Name Type

Button

Parameters

Name => <name>Name of the button.  Must be unique.
Pos|Position => [pos_x, pos_y]Position of the button.
Title => <title>Title of the button (displayed in the button).
[Frame => <frame_name>]Optional.  Name of the frame if the button is located in one.  Must be unique.  See add_frame.
[Font => [family, size, weight]]Optional.  Sets a title font.  To use the defaults set values with undef.
[Color => [<color>, <state>]]Optional.  Sets a title color.  Color can be a standard name e.g.  ‘red’ or a hex value like ‘#rrggbb’, State can be ‘normal’, ‘active’, ‘prelight’, ‘selected’ or ‘insensitive’ (see Gtk2::State).
[Size => [width, height]]Optional.  Width and height of the button.  Default is 80x25.
[Tip|Tooltip => <tooltip_text>]Optional.  Text of the tooltip shown while hovering over the button.
[Func|Function => <function_click>]Optional.  Function reference/sub.  Can be set later with add_signal_handlerNote: If data is used it have to be set as an array.
[Sig|Signal => <signal>]Optional.  The used action signal.  Only in conjunction with Func|Function.  Can be ‘activate’, ‘clicked’, ‘enter’, ‘leave’ or ‘pressed’.
[Sens|Sensitive => <sensitive>]Optional.  Sets the button active/inactive.  Default: 1 (active).

Returns

None.

Example

$win->add_button(Name => 'closeButton',
        Pos    => [10, 45],
        Title  => "_Close",
        Tip    => 'Closes the Application',
        Frame  => 'frame2');
$win->add_signal_handler('closeButton', 'clicked', sub{Gtk2->main_quit;});

References

Gtk2-Perl, Gtk2

Available Support Functions

hide_widget (<name>)

show_widget (<name>)

(x_pos, y_pos) = get_pos (<name>)

set_pos (<name>, <new_x>, <new_y>)

state = is_sensitive (<name>)

set_sensitive (<name>, <state>)

(width, height) = get_size (<name>)

set_size (<name>, <new_width>, <new_height>)

string = get_title (<name>)

set_title (<name>, <text>)

string = get_tooltip (<name>)

set_tooltip (<name>, <tooltip_text>)

GtkCheckButton

A widget that creates a discrete toggle button with label.

add_check_button

sub add_check_button #(Name = > <name>,
Position = > [pos_x, pos_y],
Title = > <title>,
[Frame => <frame_name>],  
[Active => <0/1>],  
[Font => [family, size, weight]],  
[Color => [<color>, <state>]],  
[Tooltip => <tooltip_text>],  
[Function => <function_click>],  
[Signal => <signal>],  
[Sensitive => <sensitive>]  )

Creates a new GtkCheckButton widget.

A GtkCheckButton places a discrete toggle button next to a label.

Internal Name Type

CheckButton

Parameters

Name => <name>Name of the button.  Must be unique.
Pos|Position => [pos_x, pos_y]Position of the button.
Title => <title>Title of the button (displayed in the button).
[Frame => <frame_name>]Optional.  Name of the frame if the button is located in one.  Must be unique.  See add_frame.
[Active => <0/1>]Optional.  Sets the active state.  Default: 0 (not active)
[Font => [family, size, weight]]Optional.  Sets a title font.  To use the defaults set values with undef.
[Color => [<color>, <state>]]Optional.  Sets a title color.  Color can be a standard name e.g.  ‘red’ or a hex value like ‘#rrggbb’, State can be ‘normal’, ‘active’, ‘prelight’, ‘selected’ or ‘insensitive’ (see Gtk2::State).
[Tip|Tooltip => <tooltip_text>]Optional.  Text of the tooltip shown while hovering over the button.
[Func|Function => <function_click>]Optional.  Function reference/sub.  Can be set later with add_signal_handlerNote: If data is used it have to be set as an array.
[Sig|Signal => <signal>]Optional.  The used action signal.  Only in conjunction with Func|Function.  Can be ‘activate’, ‘clicked’, ‘enter’, ‘leave’ or ‘pressed’.
[Sens|Sensitive => <sensitive>]Optional.  Sets the button active/inactive.  Default: 1 (active).

Returns

None.

Examples

$win->add_check_button( Name => 'checkEnabled' . $name_number,
        Pos     => [170, 10],
        Title   => 'Enabled',
        Tip     => "Enables or disables this output.",
        Active  => $enabled,
        Frame   => "NB_page" . $nr);
$win->add_signal_handler('checkEnabled' . $name_number, 'toggled', \&on_checkbox_enabled_toggled, $name);
--------------------------------------
$win->add_check_button(Name => 'checkButton1',
        Pos     => [80, 20],
        Title   => 'Check button',
        Tip     => 'This is a checkbox',
        Sig     => 'toggled',
        Func    => [\&DeleteFile, 'bla.txt']);

References

Gtk2-Perl, Gtk2

Available Support Functions

state = get_value (<name>, “active”)

set_value (<name>, Active => <0/1>)

state = is_active (<name>)

hide_widget (<name>)

show_widget (<name>)

(x_pos, y_pos) = get_pos (<name>)

set_pos (<name>, <new_x>, <new_y>)

state = is_sensitive (<name>)

set_sensitive (<name>, <state>)

(width, height) = get_size (<name>)

string = get_title (<name>)

set_title (<name>, <text>)

string = get_tooltip (<name>)

set_tooltip (<name>, <tooltip_text>)

GtkRadioButton

A choice from multiple check buttons.

add_radio_button

sub add_radio_button #(Name = > <name>,
Position = > [pos_x, pos_y],
Title = > <title>,
Group = > <button_group>,
[Frame => <frame_name>],  
[Active => <0/1>],  
[Font => [family, size, weight]],  
[Color => [<color>, <state>]],  
[Tooltip => <tooltip_text>],  
[Function => <function_click>],  
[Signal => <signal>],  
[Sensitive => <sensitive>]  )

Creates a new GtkRadioButton widget.

A single radio button performs the same basic function as a GtkCheckButton, as its position in the object hierarchy reflects.  It is only when multiple radio buttons are grouped together that they become a different user interface component in their own right.

Every radio button is a member of some group of radio buttons.  When one is selected, all other radio buttons in the same group are deselected.

Internal Name Type

RadioButton

Parameters

Name => <name>Name of the button.  Must be unique.
Pos|Position => [pos_x, pos_y]Position of the button.
Title => <title>Title of the button (displayed in the button).
Group => <button_group>,Name of the buttongroup.  Must be unique.
[Frame => <frame_name>]Optional.  Name of the frame if the button is located in one.  Must be unique.  See add_frame.
[Active => <0/1>]Optional.  Sets the active state.  Default: 0 (not active)
[Font => [family, size, weight]]Optional.  Sets a title font.  To use the defaults set values with undef.
[Color => [<color>, <state>]]Optional.  Sets a title color.  Color can be a standard name e.g.  ‘red’ or a hex value like ‘#rrggbb’, State can be ‘normal’, ‘active’, ‘prelight’, ‘selected’ or ‘insensitive’ (see Gtk2::State).
[Tip|Tooltip => <tooltip_text>]Optional.  Text of the tooltip shown while hovering over the button.
[Func|Function => <function_click>]Optional.  Function reference/sub.  Can be set later with add_signal_handlerNote: If data is used it have to be set as an array.
[Sig|Signal => <signal>]Optional.  The used action signal.  Only in conjunction with Func|Function.  Can be ‘activate’, ‘clicked’, ‘enter’, ‘leave’ or ‘pressed’.
[Sens|Sensitive => <sensitive>]Optional.  Sets the button active/inactive.  Default: 1 (active).

Returns

None.

Example

# Group of 3 Radio Buttons
$win->add_radio_button(Name => 'radio1', Pos => [10, 90],
        Title   => "First", Group => "radio1",
        Active  => 1, Tip => "1st radio button",
        Frame   => 'frame1');
$win->add_radio_button(Name => 'radio2', Pos => [10, 110],
        Title   => "_Second", Group => "radio1",
        Tip     => "2nd radio button", Frame => 'frame1');
$win->add_radio_button(Name => 'radio3', Pos => [10, 130],
        Title   => "Third", Group => "radio1",
        Tip     => "3rd radio button", Frame => 'frame1');

References

Gtk2-Perl, Gtk2

Available Support Functions

value = get_value (<name>, “active” or “Group” or “Groupname|Gname”)

set_value (<name>, Active => <0/1>)

state = is_active (<name>)

hide_widget (<name>)

show_widget (<name>)

(x_pos, y_pos) = get_pos (<name>)

set_pos (<name>, <new_x>, <new_y>)

state = is_sensitive (<name>)

set_sensitive (<name>, <state>)

(width, height) = get_size (<name>)

string = get_title (<name>)

set_title (<name>, <text>)

string = get_tooltip (<name>)

set_tooltip (<name>, <tooltip_text>)

GtkLinkButton

A button bound to an URL.

add_link_button

sub add_link_button #(Name = > <name>,
Position = > [pos_x, pos_y],
Title = > <title>,
Uri = > <uri-text>,
[Frame => <frame_name>],  
[Font => [family, size, weight]],  
[Color => [<color>, <state>]],  
[Size => [width, height]],  
[Function => <function_click>],  
[Signal => <signal>],  
[Sensitive => <sensitive>]  )

Creates a new GtkLinkButton widget.

A GtkLinkButton is a GtkButton with a hyperlink, similar to the one used by web browsers, which triggers an action when clicked.  It is useful to show quick links to resources.

Internal Name Type

LinkButton

Parameters

Name => <name>Name of the button.  Must be unique.
Pos|Position => [pos_x, pos_y]Position of the button.
Title => <title>Title of the button (displayed in the button).
Uri => <uri-text>A valid URI.  It is the tooltip as well and will be shown while hovering over the widget.
[Frame => <frame_name>]Optional.  Name of the frame if the button is located in one.  Must be unique.  See add_frame.
[Font => [family, size, weight]]Optional.  Sets a title font.  To use the defaults set values with undef.
[Color => [<color>, <state>]]Optional.  Sets a title color.  Color can be a standard name e.g.  ‘red’ or a hex value like ‘#rrggbb’, State can be ‘normal’, ‘active’, ‘prelight’, ‘selected’ or ‘insensitive’ (see Gtk2::State).
[Size => [width, height]]Optional.  Width and height of the button.  Default is 80x25.
[Func|Function => <function_click>]Optional.  Function reference/sub.  Can be set later with add_signal_handlerNote: If data is used it have to be set as an array.
[Sig|Signal => <signal>]Optional.  The used action signal.  Only in conjunction with Func|Function.  Can be ‘activate’, ‘clicked’, ‘enter’, ‘leave’ or ‘pressed’.
[Sens|Sensitive => <sensitive>]Optional.  Sets the button active/inactive.  Default: 1 (active).

Returns

None.

Example

$win->add_link_button(Name => 'linkButton',
        Pos     => [10, 45],
        Title   => "To SimpleGtk2 site",
        Uri     => 'https://github.com/ThomasFunk/SimpleGtk2',
        Frame   => 'frame2');
$win->add_signal_handler('linkButton', 'clicked',
                        [\&openPage, $win->get_value('linkButton', 'Uri')]);

References

Gtk2-Perl, Gtk2

Available Support Functions

state = get_value (<name>, “Uri”)

set_value (<name>, Uri => <uri-text>)

hide_widget (<name>)

show_widget (<name>)

(x_pos, y_pos) = get_pos (<name>)

set_pos (<name>, <new_x>, <new_y>)

state = is_sensitive (<name>)

set_sensitive (<name>, <state>)

(width, height) = get_size (<name>)

set_size (<name>, <new_width>, <new_height>)

string = get_title (<name>)

set_title (<name>, <text>)

Numeric/Text Data Entry

GtkEntry

A single line text entry field.

add_entry

sub add_entry #(Name = > <name>,
Position = > [pos_x, pos_y],
Size = > [width, height],
[Title => <title>],  
[Frame => <frame_name>],  
[Font => [family, size, weight]],  
[Align => <xalign>],  
[Tooltip => <tooltip_text>],  
[Function => <function_click>],  
[Signal => <signal>],  
[Sensitive => <sensitive>]  )

Creates a new GtkEntry widget.

The GtkEntry widget is a single line text entry widget.  A fairly large set of key bindings are supported by default.  If the entered text is longer than the allocation of the widget, the widget will scroll so that the cursor position is visible.

Internal Name Type

Entry

Parameters

Name => <name>Name of the entry.  Must be unique.
Pos|Position => [pos_x, pos_y]Position of the entry.
Size => [width, height]Width and height of the entry.
[Title => <title>]Optional.  Text in the entry field.
[Frame => <frame_name>]Optional.  Name of the frame if the entry is located in one.  Must be unique.  See add_frame.
[Font => [family, size, weight]]Optional.  Sets the initial font.  Font family and size are required if set.
[Align => <xalign>]Optional: Sets the alignment for the contents of the entry.  Default: left or right.
[Tip|Tooltip => <tooltip_text>]Optional.  Text of the tooltip shown while hovering over the entry.
[Func|Function => <function_click>]Optional.  Function reference/sub.  Can be set later with add_signal_handlerNote: If data is used it have to be set as an array.
[Sig|Signal => <signal>]Optional.  The used action signal.  Only in conjunction with Func|Function.  Most used are ‘activate’, ‘changed’.  For more see References below.
[Sens|Sensitive => <sensitive>]Optional.  Sets the entry active/inactive.  Default: 1 (active).

Returns

None.

Example

$win->add_entry(Name => 'entry1',
        Pos     => [200, 20],
        Size    => [100, 20],
        Title   => 'A text entry field',
        Align   => 'right');

References

Gtk2-Perl, Gtk2

Available Support Functions

string = get_value (<name>, “Align”)

set_value (<name>, Align => “<xalign>”)

hide_widget (<name>)

show_widget (<name>)

(x_pos, y_pos) = get_pos (<name>)

set_pos (<name>, <new_x>, <new_y>)

state = is_sensitive (<name>)

set_sensitive (<name>, <state>)

string = get_title (<name>)

set_title (<name>, <text>)

string = get_tooltip (<name>)

set_tooltip (<name>, <tooltip_text>)

GtkSlider

A horizontal or vertical slider widget for selecting a value from a range.

add_slider

sub add_slider #(Name = > <name>,
Position = > [pos_x, pos_y],
Orientation = > <orientation>,
[Size => [width, height]],  
[Start => <start_value>],  
Minimum = > <min_value>,
Maximum = > <max_value>,
Step = > <step_in/decrease>,
[DrawValue => <1/0>],  
[ValuePosition => <value_position>],  
[Digits => <used_digits>],  
[Frame => <frame_name>],  
[Tooltip => <tooltip_text>],  
[Function => <function_click>],  
[Signal => <signal>],  
[Sensitive => <sensitive>]  )

Creates a new GtkSlider widget.

The GtkSlider (GtkHScale/GtkVScale) widget is used to allow the user to select a value using a horizontal or vertical slider.  The position to show the current value and/or the number of decimal places can be shown, too.

Internal Name Type

Slider

Parameters

Name => <name>Name of the slider.  Must be unique.
Pos|Position => [pos_x, pos_y]Position of the slider.
Orient|Orientation => <orientation>The orientation of the slider (horizontal, vertical).
[Size => [width, height]]Optional.  Width and height of the slider.
[Start => <start_value>]Optional.  The initial start value.  Default: 0.0 (double).
Min => <min_value>The minimum allowed value (double).
Max => <max_value>The maximum allowed value (double).
Step => <step_in/decrease>The step increment (double).
[DrawValue => <1/0>]Optional.  Specifies whether the current value is displayed as a string next to the slider.
[ValuePos => <value_position>]Optional: Sets the position in which the current value is displayed.  Default: top.  Others: left, right, bottom.
[Digits => <used_digits>]Optional.  Number of decimal places the value will be displayed.  Default: 0 (1 digit).
[Frame => <frame_name>]Optional.  Name of the frame if the slider is located in one.  Must be unique.  See add_frame.
[Tip|Tooltip => <tooltip_text>]Optional.  Text of the tooltip shown while hovering over the slider.
[Func|Function => <function_click>]Optional.  Function reference/sub.  Can be set later with add_signal_handlerNote: If data is used it have to be set as an array.
[Sig|Signal => <signal>]Optional.  The used action signal.  Only in conjunction with Func|Function.  Most used signal is ‘value-changed’.  For more see References below.
[Sens|Sensitive => <sensitive>]Optional.  Sets the slider active/inactive.  Default: 1 (active).

Returns

None.

Example

$win->add_slider(Name => 'hslider',
        Pos     => [10, 220],
        Size    => [200, -1],
        Orient  => 'horizontal',
        Start   => 5,
        Min     => 0,
        Max     => 100,
        Step    => 0.1,
        Digits  => 1,
        Tip     => 'Round and round we go',
        Frame   => 'frame2');

References

Gtk2-Perl HScale, Gtk2-Perl VScale, Gtk2 HScale, Gtk2 VScale

Available Support Functions

string = get_value (<name>, “Active” or “Min|Minimum” or “Max|Maximum” or “Step” or “DrawValue” or “ValuePos|ValuePosition” or “Digits”)

set_value (<name>, Start => <start_value> or Active => <active_value> or Min => <min_value> or Max => <max_value> or Step => <step_in/decrease> or DrawValue => <1/0> or ValuePos|ValuePosition => “<value_position>” or Digits => <used_digits>)

hide_widget (<name>)

show_widget (<name>)

(x_pos, y_pos) = get_pos (<name>)

set_pos (<name>, <new_x>, <new_y>)

state = is_sensitive (<name>)

set_sensitive (<name>, <state>)

string = get_tooltip (<name>)

set_tooltip (<name>, <tooltip_text>)

GtkSpinButton

Retrieve an integer or floating-point number from the user.

add_spin_button

sub add_spin_button #(Name = > <name>,
Position = > [pos_x, pos_y],
[Size => [width, height]],  
[Start => <start_value>],  
Minimum = > <min_value>,
Maximum = > <max_value>,
Step = > <step_in/decrease>,
Page = > <page_in/decrease>,
[Snap => <snap_to_tick>],  
[Align => <xalign>],  
[Rate => <from 0.0 to 1.0>],  
[Digits => <used_digits>],  
[Frame => <frame_name>],  
[Tooltip => <tooltip_text>],  
[Function => <function_click>],  
[Signal => <signal>],  
[Sensitive => <sensitive>]  )

Creates a new GtkSpinButton widget.

A GtkSpinButton is an ideal way to allow the user to set the value of some attributes.

Rather than having to directly type a number into a GtkEntry, GtkSpinButton allows the user to click on one of two arrows to increment or decrement the displayed value.

A value can still be typed in, with the bonus that it can be checked to ensure it is in a given range.

Internal Name Type

SpinButton

Parameters

Name => <name>Name of the spin button.  Must be unique.
Pos|Position => [pos_x, pos_y]Position of the spin button.
[Size => [width, height]]Optional.  Width and height of the spin button.
[Start => <start_value>]Optional.  The initial start value.  Default: 0.0 (double).
Min => <min_value>The minimum allowed value (double).
Max => <max_value>The maximum allowed value (double).
Step => <step_in/decrease>The step increment (double).
Page => <page_in/decrease>The page increment (double).
[Snap => <snap_to_tick>]Optional.  Sets the policy as to whether values are corrected to the nearest step increment when an invalid value is provided.
[Align => <xalign>]Optional: Sets the alignment for the contents of the spin button.  Default: left or right.
[Rate => <from 0.0 to 1.0>]Optional.  Sets the amount of acceleration that the spin button has (0.0 to 1.0).  Default: 0.0
[Digits => <used_digits>]Optional.  Number of decimal places the value will be displayed.  Default: 0 (1 digit).
[Frame => <frame_name>]Optional.  Name of the frame if the spin button is located in one.  Must be unique.  See add_frame.
[Tip|Tooltip => <tooltip_text>]Optional.  Text of the tooltip shown while hovering over the spin button.
[Func|Function => <function_click>]Optional.  Function reference/sub.  Can be set later with add_signal_handlerNote: If data is used it have to be set as an array.
[Sig|Signal => <signal>]Optional.  The used action signal.  Only in conjunction with Func|Function.  Most used signal is ‘value-changed’.  For more see References below.
[Sens|Sensitive => <sensitive>]Optional.  Sets the spin button active/inactive.  Default: 1 (active).

Returns

None.

Example

$win->add_spin_button(Name => 'spin1',
        Pos     => [10, 60],
        Start   => 5,
        Min     => 0,
        Max     => 10,
        Step    => 1,
        Tip     => 'Thats a spin button',
        Align   => 'right',
        Frame   => 'frame1');

References

Gtk2-Perl, Gtk2

Available Support Functions

string = get_value (<name>, “Active” or “Align” or “Min|Minimum” or “Max|Maximum” or “Step” or “Snap” or “Rate|Climbrate” or “Digits”)

set_value (<name>, Min => <min_value> or Max => <max_value> or Step => <step_in/decrease> or Page => <page_in/decrease> or Snap => <snap_to_tick> or Align => <xalign> or Rate => <from 0.0 to 1.0> or Digits => <used_digits>)

hide_widget (<name>)

show_widget (<name>)

(x_pos, y_pos) = get_pos (<name>)

set_pos (<name>, <new_x>, <new_y>)

state = is_sensitive (<name>)

set_sensitive (<name>, <state>)

string = get_tooltip (<name>)

set_tooltip (<name>, <tooltip_text>)

Multiline Text Editor

GtkTextView

Widget that displays a GtkTextBuffer.

add_text_view

sub add_text_view #( Name = > <name>,
 Position = > [pos_x, pos_y],
 Size = > [width, height],
 Path = > <file_path>,
or Textbuffer = > <text_buffer_object>,
or Text = > <text_string>,
 [LeftMargin => <in_pixel>],  
 [RightMargin => <in_pixel>],  
 [Wrapped => <wrap_mode>],  
 [Justify => <justification>],  
 [Frame => <frame_name>],  
 [Tooltip => <tooltip_text>],  
 [Function => <function_click>],  
 [Signal => <signal>],  
 [Sensitive => <sensitive>]  )

Creates a new GtkTextView widget.

A GtkTextView is a widget which can display a GtkTextBuffer, which represents the text being edited or viewed.

Internal Name Type

TextView

Parameters

Name => <name>Name of the text view.  Must be unique.
Pos|Position => [pos_x, pos_y]Position of the text view.
Size => [width, height]Width and height of the spin button.
Path => <file_path>Path of the text file.  OR
Textbuf|Textbuffer => <text_buffer_object>Sets the buffer being displayed by the text view.  OR
Text => <text_string>Text string to display.
[LeftMargin => <in_pixel>]Optional.  Sets the default left margin for text in the text view.  Default: 0.
[RightMargin => <in_pixel>]Optional.  Sets the default right margin for text.  Default: 0.
[Wrap|Wrapped => <wrap_mode>]Optional.  Sets the line wrapping for the view.  Default: left (right, center, fill).
[Justify => <justification>]Optional.  Sets the default justification of text.  Default: none (char, word, word-char).
[Frame => <frame_name>]Optional.  Name of the frame if the text view is located in one.  Must be unique.  See add_frame.
[Tip|Tooltip => <tooltip_text>]Optional.  Text of the tooltip shown while hovering over the text view.
[Func|Function => <function_click>]Optional.  Function reference/sub.  Can be set later with add_signal_handlerNote: If data is used it have to be set as an array.
[Sig|Signal => <signal>]Optional.  The used action signal.  Only in conjunction with Func|Function.
[Sens|Sensitive => <sensitive>]Optional.  Sets the text view active/inactive.  Default: 1 (active).

Returns

None.

Example

# with file
$win->add_text_view(Name => 'tview1',
        Pos         => [40, 260],
        Size        => [200, 120],
        Tip         => 'A text',
        Frame       => 'frame2',
        Path        => './testem.txt',
        Wrapped     => 'char',
        LeftMargin  => 10,
        RightMargin => 10);

References

Gtk2-Perl, Gtk2

Available Support Functions

value = get_textview (<name>, “Path” or “Textview” or “Textbuf|Textbuffer”)

set_textview (<name>, Path => <file_path> or Textbuf|Textbuffer => <text_buffer_object> or Text => <text_string>)

string = get_value (<name>, “LeftMargin” or “RightMargin” or “Wrap|Wrapped” or “Justify”)

set_value (<name>, LeftMargin => <in_pixel> or RightMargin => <in_pixel> or Wrap|Wrapped => <wrap_mode> or Justify => <justification>)

hide_widget (<name>)

show_widget (<name>)

(x_pos, y_pos) = get_pos (<name>)

set_pos (<name>, <new_x>, <new_y>)

(width, height) = get_size (<name>)

set_size (<name>, <new_width>, <new_height>)

state = is_sensitive (<name>)

set_sensitive (<name>, <state>)

string = get_tooltip (<name>)

set_tooltip (<name>, <tooltip_text>)

get_textview

sub get_textview #(<name>,
[<keyname>])

Returns the textview reference, its’ textbuffer or the file path.  If no <keyname> is given it returns the textview reference only.

Parameters

<name>Name of the textview widget.  Must be unique.
[<keyname>]Optional.  Possible values: Path, Textview, Textbuf”|”Textbuffer.

Returns

The textview reference, its’ textbuffer or the file path.

set_textview

sub set_textview #( Name = > <name>,
 Path = > <file_path>,
or Textbuffer = > <text_buffer_object>,
or Text = > <text_string>)

Sets a new text, textbuffer or file path.

Parameters

Name => <name>Name of the text view.  Must be unique.
Path => <file_path>”Path of the new text file.  OR
Textbuf|Textbuffer => <text_buffer_object>A new buffer being displayed by the text view.  OR
Text => <text_string>A new Text string to display.

Returns

None.

Tree and List Widgets

GtkTreeView

A widget for displaying both trees and lists.

add_treeview

sub add_treeview #(Name = > <name>,
Type = > <List|Tree>,
Position = > [pos_x, pos_y],
Size = > [width, height],
Headers = > [<Array_of_column_pairs>],
[Data => [<Array_of_arrays>]],  
[Treeview => <Gtk2::TreeView>],  
[Mode => <selection mode>],  
[Frame => <frame_name>],  
[Function => <function_click>],  
[Signal => <signal>],  
[Sensitive => <sensitive>]  )

Creates a new GtkTreeView widget.

A Widget that displays List and Tree objects implemented by the GtkTreeModel interface.

Internal Name Type

List or Tree

Parameters

Name => <name>Name of the tree view.  Must be unique.
Type => <List|Tree>Type of the tree view.  ‘List’ or ‘Tree’.
Pos|Position => [pos_x, pos_y]Position of the tree view.
Size => [width, height]Width and height of the tree view.
Headers => [<Array_of_column_pairs>]]List of <column_text> => <column_type>.
[Data => [<Array_of_arrays>]]Optional.  Data of the list or tree.  Can be set later with set_value.
[Treeview => <Gtk2::TreeView>Optional.  An existing Gtk2::TreeView object.
[Mode => <selection mode>]Optional.  Set selection mode.  Default is ‘single’.  Other possibilities: ‘none’, ‘browse’ and ‘multiple’.
[Frame => <frame_name>]Optional.  Name of the frame if the text view is located in one.  Must be unique.  See add_frame.
[Func|Function => <function_click>]Optional.  Function reference/sub.  Can be set later with add_signal_handlerNote: If data is used it have to be set as an array.
[Sig|Signal => <signal>]Optional.  The used action signal.  Only in conjunction with Func|Function.  Most used is ‘cursor-changed’.
[Sens|Sensitive => <sensitive>]Optional.  Sets the tree view active/inactive.  Default: 1 (active).

Possible column types

textNormal text strings.
intInteger values.
doubleDouble-precision floating point values.
boolBoolean values, displayed as toggle-able checkboxes.
scalarA perl scalar, displayed as a text string by default.
pixbufA Gtk2::Gdk::Pixbuf.

Returns

None.

Example

# list
$win->add_treeview(Name => 'slist',
        Type    => 'List',
        Pos     => [10, 10],
        Size    => [150, 150],
        Headers => ['No'    => 'int',
                    'Text1' => 'text',
                    'Text2' => 'text'],
        Data    => [[1, 'bla', 'lol'],
                    [2, 'snore', 'moe'],
                    [3, 'yalla', 'meh']]);
$window->add_signal_handler('slist', 'cursor-changed', \&show_index);
--------------------------------------
# tree
$win->add_treeview(Name => 'stree',
        Type    => 'Tree',
        Pos     => [10, 10],
        Size    => [350, 320],
        Headers => $headers,
        Data    => \@tree,
        Sens    => 1);

References

Gtk2-Perl, Gtk2

Available Support Functions

reference = get_treeview (<name>, “List” or “Tree”)

set_value (<name>, mode => <selection_mode> or sortable => <0/1> or reordable => <0/1>)

hide_widget (<name>)

show_widget (<name>)

(x_pos, y_pos) = get_pos (<name>)

set_pos (<name>, <new_x>, <new_y>)

(width, height) = get_size (<name>)

set_size (<name>, <new_width>, <new_height>)

state = is_sensitive (<name>)

set_sensitive (<name>, <state>)

List only Support Functions

value = get_value (<name>, “Editable” or “Path” or “Cell”)

set_value (<name>, select => <row|[row_list]> or unselect => <row|[row_list]>)

Tree only Support Functions

value = get_value (<name>, “Iter” or “Path” or “Row”)

set_value (<name>, iter => <iter> or path => <path_object> or row => [row_values])

get_treeview

sub get_treeview #(<name>,
[<keyname>])

Returns the treeview reference.

Parameters

<name>Name of the treeview widget.  Must be unique.
[<keyname>]Optional.  Possible values: “List” or “Tree”.

Returns

The textview reference, its’ textbuffer or the file path.

Combo Box and Menus

GtkComboBox

A widget used to choose from a list of items.

add_combo_box

sub add_combo_box #(Name = > <name>,
Position = > [pos_x, pos_y],
Data = > [Array_of_values>],
[Start => <start_value>],  
[Size => [width, height]],  
[Frame => <frame_name>],  
[Tooltip => <tooltip_text>],  
[Function => <function_click>],  
[Signal => <signal>],  
[Sensitive => <sensitive>]  )

Creates a new GtkComboBox widget.

A GtkComboBox is a widget that allows the user to choose from a list of valid choices.  The GtkComboBox displays the selected choice.  When activated, the GtkComboBox displays a popup which allows the user to make a new choice.

Internal Name Type

ComboBox

Parameters

Name => <name>Name of the combo box.  Must be unique.
Pos|Position => [pos_x, pos_y]Position of the combo box.
Data => [Array_of_values>]Array of values/strings being displayed in the combo box.
[Start => <start_value>]Optional.  Sets the active item of the combo box to be the item at index.  Default: 0.
[Size => [width, height]]Optional.  Width and height of the combo box.
[Frame => <frame_name>]Optional.  Name of the frame if the combo box is located in one.  Must be unique.  See add_frame.
[Tip|Tooltip => <tooltip_text>]Optional.  Text of the tooltip shown while hovering over the combo box.
[Func|Function => <function_click>]Optional.  Function reference/sub.  Can be set later with add_signal_handlerNote: If data is used it have to be set as an array.
[Sig|Signal => <signal>]Optional.  The used action signal.  Only in conjunction with Func|Function.  Most used signal is ‘changed’.  For more see References below.
[Sens|Sensitive => <sensitive>]Optional.  Sets the combo box active/inactive.  Default: 1 (active).

Returns

None.

Example

$win->add_combo_box(Name => 'combo1',
        Pos     => [100, 60],
        Data    => ['one', 'two', 'three', 'four'],
        Start   => 1,
        Tip     => 'Jup',
        Frame   => 'frame1');

References

Gtk2-Perl, Gtk2

Available Support Functions

state = is_active (<name>, <value|string>)

string = get_value (<name>, “Active” or “Data” or “Columns”)

set_value (<name>, Active => “<active_index>” or Data => [<Array_of_values>] or Columns => <wrap_list_to_x_columns>)

hide_widget (<name>)

show_widget (<name>)

(x_pos, y_pos) = get_pos (<name>)

set_pos (<name>, <new_x>, <new_y>)

state = is_sensitive (<name>)

set_sensitive (<name>, <state>)

string = get_title (<name>)

set_title (<name>, <text>)

string = get_tooltip (<name>)

set_tooltip (<name>, <tooltip_text>)

GtkMenuBar

A standard menu bar.

add_menu_bar

sub add_menu_bar #(Name = > <name>,
Position = > [pos_x, pos_y],
[Size => [width, height]]  )

Creates a new GtkMenuBar widget.

The GtkMenuBar is a subclass of GtkMenuShell which contains one to many GtkMenuItem.  The result is a standard menu bar which can hold many menu items.

Internal Name Type

MenuBar

Parameters

Name => <name>Name of the menu bar.  Must be unique.
Pos|Position => [pos_x, pos_y]Position of the menu bar.
[Size => [width, height]]Optional.  Width and height of the menu bar.  Default: at top of the window.

Returns

None.

Example

$win->add_menu_bar(Name => 'menubar1', Pos => [0,0]);

References

Gtk2-Perl, Gtk2

Available Support Functions

hide_widget (<name>)

show_widget (<name>)

(width, height) = get_size (<name>)

set_size (<name>, <new_width>, <new_height>)

(x_pos, y_pos) = get_pos (<name>)

set_pos (<name>, <new_x>, <new_y>)

GtkMenu

A menu widget.

add_menu

sub add_menu #(Name = > <name>,
Menubar = > <menu_bar>,
Title = > <title>,
[Justify => <justification>],  
[Sensitive => <sensitive>]  )

Creates a new GtkMenu widget.

A GtkMenu is a GtkMenuShell that implements a drop down menu consisting of a list of GtkMenuItem objects which can be navigated and activated by the user to perform application functions.

A GtkMenu is most commonly dropped down by activating a GtkMenuItem in a GtkMenuBar or popped up by activating a GtkMenuItem in another GtkMenu.

Internal Name Type

Menu

Parameters

Name => <name>Name of the menu.  Must be unique.
Menubar => <menu_bar>Name of the menu bar the menu is registered.  Must be unique.  See <add_menubar>.
Title => <title>Text of the menu.  An underline at the beginning of the text actvates a hotkey.
[Justify => <justification>]Optional.  The position in the menu bar.  Default: left (right).
[Sens|Sensitive => <sensitive>]Optional.  Sets the menu active/inactive.  Default: 1 (active).

Returns

None.

Example

# menu Edit
$win->add_menu(Name => 'menu_edit',
        Title   => '_Edit',
        Menubar => 'menubar1');

References

Gtk2-Perl, Gtk2

Available Support Functions

string = get_value (<name>, “Justify”)

set_value (Justify => <justification>)

state = is_sensitive (<name>)

set_sensitive (<name>, <state>)

(width, height) = get_size (<name>)

string = get_title (<name>)

set_title (<name>, <text>)

GtkMenuItem

The widget used for item in menus.

add_menu_item

sub add_menu_item #(Name = > <name>,
Menu = > <menu_name>,
[Type => <type>],  
[Title => <title>],  
[Tip|Tooltip => <tooltip_text>],  
[Icon => <path|stock|name>],  
Group = > <group_name>,
Active = > <0/1>,
[Func|Function => <function>],  
[Sig|Signal => <signal>],  
[Sens|Sensitive => <sensitive>]  )

Creates a new GtkMenuItem widget.

The GtkMenuItem widget and the derived widgets are the only valid childs for menus.

Their function is to correctly handle highlighting, alignment, events and submenus.

Internal Name Types

MenuItem, TearOffMenuItem, SeparatorMenuItem, RadioMenuItem or CheckMenuItem

Parameters

Name => <name>Name of the menu item.  Must be a unique.
Menu => <menu_name>Name of the menu which shall hold the menu item.  Must be a unique.  See add_menu.
[Type => <type>]Optional.  Menu item type.  Default: Item.  Others are: tearoff, radio, check, separator.
[Title => <title>]Optional.  Title of the menu item.  Not available for tearoff and separator.
[Tip|Tooltip => <tooltip_text>]Optional.  Text of the tooltip shown while hovering over the menu item.  Not available for separator.
[Icon => <path|stock|name>]Optional.  Path of an icon, stock id or icon name on a standard menu item.  Not available for separator.
Group => <group_name>Name of the radio menu group the menu item is associated to.  Must be unique.
Active => <0/1>Sets the status of the radio menu.  Only one in the group can be set to 1!  Default: 0
[Func|Function => <function>]Optional.  Function reference/sub.  Can be set later with add_signal_handlerNote: If data is used it have to be set as an array.
[Sig|Signal => <signal>]Optional.  Signal/event.  Only in conjunction with ‘Func’.
[Sens|Sensitive => <sensitive>]Optional.  Set menu item active/inactive.  Default: 1 (active).

Returns

None.

Example

# menu tearoff
$win->add_menu_item(Name => 'menu_item_toff',
        Type    => 'tearoff',
        Menu    => 'menu_edit',
        Tip     => 'This is a tearoff');

# menu item Save
$win->add_menu_item(Name => 'menu_item_save',
        Icon    => 'gtk-save',
        Menu    => 'menu_edit',
        Tip     => 'This is the Save entry');

# separator
$win->add_menu_item(Name => 'menu_item_sep1',
        Type    => 'separator',
        Menu    => 'menu_edit');

# icon
$win->add_menu_item(Name => 'menu_item_icon',
        Title   => 'Burger',
        Icon    => './1.png',
        Menu    => 'menu_edit',
        Tip     => 'This is a Burger');

# check menu
$win->add_menu_item(Name => 'menu_item_check',
        Type    => 'check',
        Title   => 'Check em',
        Menu    => 'menu_edit',
        Tip     => 'This is a Check menu',
        Active  => 1);

# radio menu
$win->add_menu_item(Name => 'menu_item_radio1',
        Type    => 'radio',
        Title   => 'First',
        Menu    => 'menu_edit',
        Tip     => 'First radio',
        Group   => 'Yeah',
        Active  => 1);
$win->add_menu_item(Name => 'menu_item_radio2',
        Type    => 'radio',
        Title   => 'Second',
        Menu    => 'menu_edit',
        Tip     => 'Second radio',
        Group   => 'Yeah');
$win->add_menu_item(Name => 'menu_item_radio3',
        Type    => 'radio',
        Title   => '_Third',
        Menu    => 'menu_edit',
        Tip     => 'Third radio',
        Group   => 'Yeah');

References

Gtk2-Perl MenuItem, RadioMenuItem, CheckMenuItem, SeparatorMenuItem, TearoffMenuItem

Gtk2 MenuItem, RadioMenuItem, CheckMenuItem, SeparatorMenuItem, TearoffMenuItem

Available Support Functions

string = get_value (<name>, “IconPath” or “StockIcon” or “IconName” or “Icon” or “Active” or “Group” or “Groupname|Gname”)

set_value (Icon => <path|stock|name> or Active => <0/1>)

state = is_sensitive (<name>)

set_sensitive (<name>, <state>)

(width, height) = get_size (<name>)

string = get_title (<name>)

set_title (<name>, <text>)

string = get_tooltip (<name>)

set_tooltip (<name>, <tooltip_text>)

Selectors (File/Font)

GtkFileChooserButton

A button to launch a file selection dialog.

add_filechooser_button

sub add_filechooser_button #(
   Name = > <name>,
   Position = > [pos_x, pos_y],
   Title = > <title>,
   Action = > <open_mode>,
   [Frame => <frame_name>],  
   [File => <file_path>],  
   [Filter => <pattern|mimetype> | [<name>, <pattern|mimetype>]],  
   [Folder => <directory>],  
   [Size => [width, height]],  
   [Function => <function_click>],  
   [Signal => <signal>],  
   [Sensitive => <sensitive>]  
)

Creates a new GtkFileChooserButton widget.

The GtkFileChooserButton is a widget that lets the user select a file or folder.  It implements the GtkFileChooser interface.

Internal Name Type

FileChooserButton

Parameters

Name => <name>Name of the button.  Must be unique.
Pos|Position => [pos_x, pos_y]Position of the button.
Title => <title>Title of the button (displayed in the button).
Action => <open_mode>Sets the mode which confirmation dialog should appear.  The open modes are: ‘open’ and ‘select-folder’.
[Frame => <frame_name>]Optional.  Name of the frame if the button is located in one.  Must be unique.  See add_frame.
[File => <file_path>]Optional.  Sets a file path for ‘open’ action.
[Filter => <pattern|mimetype> | [<name>, <pattern|mimetype>]]Optional.  Sets the current file filter for ‘open’ action.
[Folder => <directory>]Optional.  Sets a directory for ‘select-folder’ action or if no file path is set for ‘open’ action.
[Size => [width, height]]Optional.  Width and height of the button.  Default is 80x25.
[Tip|Tooltip => <tooltip_text>]Optional.  Text of the tooltip shown while hovering over the button.
[Func|Function => <function_click>]Optional.  Function reference/sub.  Can be set later with add_signal_handlerNote: If data is used it have to be set as an array.
[Sig|Signal => <signal>]Optional.  The used action signal.  Only in conjunction with Func|Function.  Can be ‘activate’, ‘clicked’, ‘enter’, ‘leave’ or ‘pressed’.
[Sens|Sensitive => <sensitive>]Optional.  Sets the button active/inactive.  Default: 1 (active).

Returns

None.

Example

# show only images. Start folder is ~/Pictures
$win->add_filechooser_button(Name => 'FButton2',
        Pos     => [40, 70],
        Size    => [120, 40],
        Title   => "Select an image",
        Action  => 'open',
        Folder  => "$ENV{HOME}/Pictures",
        Filter  => ['Images', '*.png']);

References

Gtk2-Perl, Gtk2

Available Support Functions

string = get_value (<name>, )

set_value ()

hide_widget (<name>)

show_widget (<name>)

(x_pos, y_pos) = get_pos (<name>)

set_pos (<name>, <new_x>, <new_y>)

state = is_sensitive (<name>)

set_sensitive (<name>, <state>)

(width, height) = get_size (<name>)

set_size (<name>, <new_width>, <new_height>)

string = get_title (<name>)

set_title (<name>, <text>)

string = get_tooltip (<name>)

set_tooltip (<name>, <tooltip_text>)

GtkFileChooserDialog

A file chooser dialog.

add_filechooser_dialog

sub add_filechooser_dialog #(
   Name = > <name>,
   Action = > <open_mode>,
   [Title => <title>],  
   [FName => <file_name>],  
   [Filter => <pattern|mimetype> | [<name>, <pattern|mimetype>]],  
   [Folder => <directory>],  
   [RFunc => <response_function>]  
)

Creates a new GtkFileChooserDialog widget.

GtkFileChooserDialog is a dialog box suitable for use with “File/Open” or “File/Save as” commands.

Internal Name Type

FileChooserDialog

Parameters

Name => <name>Name of the dialog.  Must be unique.
Action => <open_mode>Sets the mode which confirmation dialog should appear.  The open modes are: ‘open’, ‘save’, ‘select-folder’ and ‘create-folder’.
[Title => <title>]Optional.  Title of the dialog (displayed in the dialog titlebar).
[File => <file_name>]Optional.  Sets the default file name for ‘open’ or ‘save’ action.
[Filter => <pattern|mimetype> | [<name>, <pattern|mimetype>]]Optional.  Sets the current file filter for ‘open’ action.
[Folder => <directory>]Optional.  Sets a directory for ‘select-folder’ action or if no file path in show_filechooser_dialog is set for ‘open’ or ‘save’ action.
[RFunc => <response_function>]Optional.  If not set show_filechooser_dialog will return the response.

Returns

The chosen path/folder or 0.

Example

sub response {
    my $resp = shift;
    print "response: " . $resp . "\n";
}

my $win = SimpleGtk2->new_window(Name => 'mainWindow',
                        Title   => 'File Chooser dialog',
                        Size    => [200, 100]);

$win->add_button( Name => 'tryButton',
        Pos     => [20, 15],
        Size    => [80, 25],
        Title   => "Try");
$win->add_signal_handler('tryButton', 'clicked', sub{$win->show_filechooser_dialog('fchooserdiag');});

$win->add_filechooser_dialog(Name => 'fchooserdiag',
        Title   => 'Open a file',
        Action  => 'open',
        RFunc   => \&response);

References

Gtk2-Perl, Gtk2

Available Support Functions

response = show_filechooser_dialog (<name>, <filename|file|folder>)

string = get_value (<name>, )

set_value ()

string = get_title (<name>)

set_title (<name>, <text>)

show_filechooser_dialog

sub show_filechooser_dialog #(
   <name>,
   <filename|file|folder>
), or (<action_type>, <filename|file|folder>, <pattern|mimetype>, or [<name>, <pattern|mimetype>])

Shows a simple or normal filechooser dialog.

The normal filechooser dialog needs a filechooser dialog object created with add_filechooser_dialog.

The simple filechooser dialog doesn’t need this object.

Parameters for normal

<name>Name of the filechooser dialog.  Must be unique.
<filename|file|folder>The filename or file path or folder.

Parameters for simple

<action_type>The mode which confirmation dialog should appear.  Could be: ‘open’, ‘save’, ‘select-folder’ and ‘create-folder’.
<filename|file|folder>The filename for ‘open’ or ‘save’ action,
<pattern|mimetype> | [<name>, <pattern|mimetype>]The used file filter for ‘open’ action.

Returns

The chosen path/folder or 0.

Examples

# A simple filechooser dialog

sub response {
    my $win = shift;
    my $resp = $win->show_filechooser_dialog('create-folder');
    print "response: " . $resp . "\n";
}

$win->add_button( Name => 'tryButton',
        Pos     => [70, 45],
        Size    => [80, 25],
        Tip     => "Shows a simple filechooser dialog.",
        Title   => "Simple");
$win->add_signal_handler('tryButton', 'clicked', sub{&response($win);});
--------------------------------------
# A normal filechooser dialog

sub response {
    my $resp = shift;
    print "response: " . $resp . "\n";
}

$win->add_button( Name => 'tryButton',
        Pos     => [70, 15],
        Size    => [80, 25],
        Tip     => "Shows a normal filechooser dialog.",
        Title   => "Normal");
$win->add_signal_handler('tryButton', 'clicked', sub{$win->show_filechooser_dialog('fchooserdiag');});

$win->add_filechooser_dialog(Name => 'fchooserdiag',
        Title   => 'Open a file',
        Action  => 'open',
        RFunc => \&response);

GtkFontButton

A button to launch a font selection dialog.

add_font_button

sub add_font_button #(Name = > <name>,
Position = > [pos_x, pos_y],
Title = > <title>,
Action = > <open_mode>,
[Frame => <frame_name>],  
[Font => [family, size, weight]],  
[Size => [width, height]],  
[Function => <function_click>],  
[Signal => <signal>],  
[Sensitive => <sensitive>]  )

Creates a new GtkFontButton widget.

The GtkFontButton is a button which displays the currently selected font an allows to open a font selection dialog to change the font.

Internal Name Type

FontButton

Parameters

Name => <name>Name of the button.  Must be unique.
Pos|Position => [pos_x, pos_y]Position of the button.
Title => <title>Title of the button (displayed in the button).
[Frame => <frame_name>]Optional.  Optional.  Name of the frame if the button is located in one.  Must be unique.  See add_frame.
[Font => [family, size, weight]]Optional.  Sets the initial font.  Font family and size are required if set.
[Size => [width, height]]Optional.  Width and height of the button.  Default is 80x25.
[Tip|Tooltip => <tooltip_text>]Optional.  Text of the tooltip shown while hovering over the button.
[Func|Function => <function_click>]Optional.  Function reference/sub.  Can be set later with add_signal_handlerNote: If data is used it have to be set as an array.
[Sig|Signal => <signal>]Optional.  The used action signal.  Only in conjunction with Func|Function.  Can be ‘activate’, ‘clicked’, ‘enter’, ‘leave’ or ‘pressed’.
[Sens|Sensitive => <sensitive>]Optional.  Sets the button active/inactive.  Default: 1 (active).

Returns

None.

Example

$window->add_font_button(Name => 'font_button',
            Pos     => [20, 40],
            Font    => ["Arial", 12]);

References

Gtk2-Perl, Gtk2

Available Support Functions

string = get_value (<name>, “Uri”)

set_value (<name>, Uri => <uri-text>)

hide_widget (<name>)

show_widget (<name>)

(x_pos, y_pos) = get_pos (<name>)

set_pos (<name>, <new_x>, <new_y>)

state = is_sensitive (<name>)

set_sensitive (<name>, <state>)

(width, height) = get_size (<name>)

set_size (<name>, <new_width>, <new_height>)

string = get_title (<name>)

set_title (<name>, <text>)

string = get_tooltip (<name>)

set_tooltip (<name>, <tooltip_text>)

GtkFontSelectionDialog

A dialog box for selecting fonts.

add_fontselection_dialog

sub add_fontselection_dialog #(Name = > <name>,
Title = > <title>,
[Font => [family, size, weight]],  
[Preview => <preview text>],  
[RFunc => <response_function>]  )

Creates a new GtkFontSelectionDialog widget.

The GtkFontSelectionDialog widget is a dialog box for selecting a font.

Internal Name Type

FontSelectionDialog

Parameters

Name => <name>Name of the dialog.  Must be unique.
Title => <title>Title of the dialog (displayed in the dialog titlebar).
[Font => [family, size, weight]]Optional.  Sets the initial font.  Font family and size are required if set.
[Preview => <preview text>]Optional.  Sets the previewed text.
[RFunc => <response_function>]Optional.  If not set <show_font_dialog> will return the response.

Returns

The font string: “fontname weight size” or 0.

Example

References

Gtk2-Perl, Gtk2

Available Support Functions

response = <show_font_dialog> (<name>)

string = get_value (<name>, “previewstring” or “fontstring” or “fontfamily” or “fontsize” or “fontweight”)

set_value (<name>, previewstring => <preview_text> or fontstring => <font_string> or fontfamily => <font_family> or fontsize => <font_size> or fontweight => <font_weight>)

string = get_title (<name>)

set_title (<name>, <text>)

show_fontselection_dialog

sub show_fontselection_dialog #(<name>) or (<family>, <size>, <weight>)

Shows simple or normal fontselection dialog.

The normal fontselection dialog needs a fontselection dialog object created with add_fontselection_dialog.

The simple fontselection dialog doesn’t need this object.

Parameters for normal

<name>Name of the fontselection dialog.  Must be unique.

Parameters for simple

<family>The initial font family.
<size>The initial font size.
<weight>The initial font weight.

Returns

The font string: “fontname weight size” or 0.

Examples

# A simple fontselection dialog
--------------------------------------
# A normal fontselection dialog

Layout Containers

GtkNotebook

A tabbed notebook container.

add_notebook

sub add_notebook #(Name = > <name> ,
Pos|Position = > [pos_x, pos_y],
Size = > [width, height],
[Tabs => <position>],  
[Scroll|Scrollable => <0/1>],  
[Popup => <0/1>],  
[Frame => <frame_name>],  
[Sens|Sensitive => <sensitive>]  )

Creates a new GtkNotebook widget.

The GtkNotebook widget is a GtkContainer whose children are pages that can be switched between using tab labels along one edge.

There are many configuration options for GtkNotebook.  Among other things, you can choose on which edge the tabs appear (whether, if there are too many tabs to fit the notebook should be made bigger or scrolling arrows added, and whether there will be a popup menu allowing the users to switch pages.

Internal Name Type

Notebook

Parameters

Name => <name>Name of the notebook.  Must be unique.
Pos|Position => [pos_x, pos_y]Position of the notebook.
Size => [width, height]Width and height of the notebook.
[Tabs => <position>]Optional.  Sets the edge at which the tabs for switching pages in the notebook are drawn.  Default: top (left, right, bottom, none).
[Scroll|Scrollable => <0/1>]Optional.  Sets whether the tab label area will have arrows for scrolling if there are too many tabs to fit in the area.  Default: 1.
[Popup => <0/1>]Optional.  Enables (1) the popup menu: if the user clicks with the right mouse button on the tab labels, a menu with all the pages will be popped up.
[Frame => <frame_name>]Optional.  Name of the frame if the notebook is located in one.  Must be unique.  See add_frame.
[Sens|Sensitive => <sensitive>]Optional.  Sets the notebook active/inactive.  Default: 1 (active).

Returns

None.

Example

$win->add_notebook(Name => 'NB1',
        Pos     => [10, 10],
        Size    => [200, 200],
        Tabs    => 'top',
        Popup   => 1);

References

Gtk2-Perl, Gtk2

Available Support Functions

add_nb_page (Name => <name>, Notebook => <notebook_name>, [Font => [family, size, weight]], [Color => [<color>, <state>]], [Pos_n|PositionNumber => <number>], [Tip|Tooltip => <tooltip_text>], [Sens|Sensitive => <sensitive>])

remove_nb_page (<nb_name>, <title|number>)

string = get_value (<name>, “Current|CurrentPage” or “Pages” or “Popup” or “No2Name|Number2Name” or “Scroll|Scrollable” or “Tabs”)

set_value (<name>, Current|CurrentPage => <page_number|next|prev> or Popup => <0/1> or Scroll|Scrollable => <0/1> or Tabs => <edges>)

hide_widget (<name>)

show_widget (<name>)

(x_pos, y_pos) = get_pos (<name>)

set_pos (<name>, <new_x>, <new_y>)

state = is_sensitive (<name>)

set_sensitive (<name>, <state>)

(width, height) = get_size (<name>)

set_size (<name>, <new_width>, <new_height>)

GtkNotebookPage

A notebook page.

add_nb_page

sub add_nb_page #(Name = > <name>,
Notebook = > <notebook_name>,
[Font => [family, size, weight]],  
[Color => [<color>, <state>]],  
[Pos_n|PositionNumber => <number>],  
[Tip|Tooltip => <tooltip_text>],  
[Sens|Sensitive => <sensitive>]  )

Creates a new GtkNotebook page.

Appends a new page to a notebook.  The index starting from 0.

Internal Name Type

NotebookPage

Parameters

Name => <name>Name of the notebook page.  Must be unique.
Title => <title>Title of the notebook page (displayed in the tab).
Notebook => <notebook_name>Name of the notebook where the page shall appear.  Must be unique.
[Font => [family, size, weight]]Optional.  Sets a title font.  To use the defaults set values with undef.
[Color => [<color>, <state>]]Optional.  Sets a title color.  Color can be a standard name e.g.  ‘red’ or a hex value like ‘#rrggbb’, State can be ‘normal’, ‘active’, ‘prelight’, ‘selected’ or ‘insensitive’ (see Gtk2::State).
[Pos_n|PositionNumber => <number>]Optional.  Insert a page into the notebook at the given position.
[Tip|Tooltip => <tooltip_text>]Optional.  Text of the tooltip shown while hovering over the page.
[Sens|Sensitive => <sensitive>]Optional.  Sets the notebook page active/inactive.  Default: 1 (active).

Returns

None.

Example

$win->add_nb_page(Name => "NB_page1",
        Pos_n   => 0,
        Title   => "Page 1",
        Notebook => 'NB1',
        Tip     => "This is the first page");

References

Gtk2-Perl, Gtk2

Available Support Functions

string = get_value (<name>, “PageNumber” or “Notebook”)

set_value (<name>, Reorder => <0/1>)

state = is_sensitive (<name>)

set_sensitive (<name>, <state>)

string = get_title (<name>)

set_title (<name>, <text>)

string = get_tooltip (<name>)

set_tooltip (<name>, <tooltip_text>)

remove_nb_page

sub remove_nb_page #(<nb_name>,
<title|number>)

Removes a notebook page from a notebook.

Parameters

<nb_name>Name of the notebook.  Must be unique.
<title|number>Title or number (0 indexed) of the notebook page.

Returns

None.

Ornaments

GtkFrame

A bin with a decorative frame and optional label.

add_frame

sub add_frame #(Name = > <name>,
Position = > [pos_x, pos_y],
[Title => <title>],  
[Frame => <frame_name>],  
[Font => [family, size, weight]],  
[Tooltip => <tooltip_text>],  
[Sensitive => <sensitive>]  )

Creates a new GtkFrame widget.

The frame widget is a Bin that surrounds its child with a decorative frame and an optional label.  If present, the label is drawn in a gap in the top side of the frame.

Internal Name Type

Frame

Parameters

Name => <name>Name of the frame.  Must be unique.
Size => [width, height]Width and height of the frame.
Pos|Position => [pos_x, pos_y]Position of the frame.  Note: Inside a frame the positioning of a widget starts at the frame and not at the window edges.
[Title => <title>]Optional.  Title of the frame.
[Frame => <frame_name>]Optional.  Name of the frame if the frame is located in one.  Must be unique.  See add_frame.
[Font => [family, size, weight]]Optional.  Sets the initial font.  Font family and size are required if set.
[Tip|Tooltip => <tooltip_text>]Optional.  Text of the tooltip shown while hovering over the frame.
[Sens|Sensitive => <sensitive>]Optional.  Sets the frame active/inactive.  Default: 1 (active).  Note: All widgets inside the frame will be deactivated if frame is set to inactive.

Returns

None.

Example

$win->add_frame(Name => 'frame1',
                Pos => [5, 5],
                Size => [390, 190],
                Title => ' A Frame around ');

References

Gtk2-Perl, Gtk2

Available Support Functions

hide_widget (<name>)

show_widget (<name>)

(x_pos, y_pos) = get_pos (<name>)

set_pos (<name>, <new_x>, <new_y>)

state = is_sensitive (<name>)

set_sensitive (<name>, <state>)

string = get_title (<name>)

set_title (<name>, <text>)

string = get_tooltip (<name>)

set_tooltip (<name>, <tooltip_text>)

GtkSeparator

A horizontal or vertical separator.

add_separator

sub add_separator #(Name = > <name>,
Orient|Orientation = > <orientation>,
Pos|Position = > [pos_x, pos_y],
[Size => [width, height]],  
[Frame => <frame_name>],  
[Sens|Sensitive => <sensitive>]  )

Creates a new GtkSeparator widget.

The GtkSeparator (GtkHSeparator/GtkVSeparator) widget is a horizontal or vertical separator, used to group the widgets within a window.  It displays a horizontal/vertical line with a shadow to make it appear sunken into the interface.

Note: The GtkSeparator widget is not used as a separator within menus.  To create a separator in a menu create an empty GtkSeparatorMenuItem in add_menu_item.

Internal Name Type

Separator

Parameters

Name => <name>Name of the separator.  Must be unique.
Orient|Orientation => <orientation>Orientation of the separator (horizontal, vertical).
Pos|Position => [pos_x, pos_y]Position of the separator.
[Size => [width, height]]Optional.  Width and height of the separator.
[Frame => <frame_name>]Optional.  Name of the frame if the separator is located in one.  Must be unique.  See add_frame.
[Sens|Sensitive => <sensitive>]Optional.  Sets the separator active/inactive.  Default: 1 (active).

Returns

None.

Example

References

Gtk2-Perl GtkHSeparator, Gtk2-Perl GtkVSeparator, Gtk2 GtkHSeparator Gtk2 GtkVSeparator

Available Support Functions

hide_widget (<name>)

show_widget (<name>)

(x_pos, y_pos) = get_pos (<name>)

set_pos (<name>, <new_x>, <new_y>)

state = is_sensitive (<name>)

set_sensitive (<name>, <state>)

Scrolling

GtkScrollBar

A horizontal or vertical scrollbar.

add_scrollbar

sub add_scrollbar #(Name = > <name>,
Position = > [pos_x, pos_y],
Orientation = > <orientation>,
[Size => [width, height]],  
[Start => <start_value>],  
Minimum = > <min_value>,
Maximum = > <max_value>,
Step = > <step_value>,
[Digits => <used_digits>],  
[Frame => <frame_name>],  
[Tooltip => <tooltip_text>],  
[Function => <function_click>],  
[Signal => <signal>],  
[Sensitive => <sensitive>]  )

Creates a new GtkScrollBar widget.

The GtkScrollBar widget is a widget arranged horizontally or vertically creating a scrollbar.

Internal Name Type

Scrollbar

Parameters

Name => <name>Name of the slider.  Must be unique.
Pos|Position => [pos_x, pos_y]Position of the scrollbar.
Orient|Orientation => <orientation>The orientation of the scrollbar (horizontal, vertical).
[Size => [width, height]]Optional.  Width and height of the scrollbar.
[Start => <start_value>]Optional.  The initial start value.  Default: 0.0 (double).
Min => <min_value>The minimum allowed value (double).
Max => <max_value>The maximum allowed value (double).
Step => <step_in/decrease>The step increment (double).
[Digits => <used_digits>]Optional.  Number of decimal places the value will be displayed.  Default: 0 (1 digit).
[Frame => <frame_name>]Optional.  Name of the frame if the scrollbar is located in one.  Must be unique.  See add_frame.
[Tip|Tooltip => <tooltip_text>]Optional.  Text of the tooltip shown while hovering over the scrollbar.
[Func|Function => <function_click>]Optional.  Function reference/sub.  Can be set later with add_signal_handlerNote: If data is used it have to be set as an array.
[Sig|Signal => <signal>]Optional.  The used action signal.  Only in conjunction with Func|Function.  Most used signal is ‘value-changed’.  For more see References below.
[Sens|Sensitive => <sensitive>]Optional.  Sets the scrollbar active/inactive.  Default: 1 (active).

Returns

None.

Examples

# Horizontal
$win->add_scrollbar(Name => 'hscroll',
        Pos     => [10, 220],
        Size    => [200, -1],
        Orient  => 'horizontal',
        Start   => 5,
        Min     => 0,
        Max     => 100,
        Step    => 1,
        Digits  => 1,
        Tip     => 'From left to right',
        Frame   => 'frame2');

# Vertical
$win->add_scrollbar(Name => 'vscroll',
        Pos     => [320, 30],
        Size    => [-1, 150],
        Orient  => 'vertical',
        Start   => 1.5,
        Min     => 0,
        Max     => 100,
        Step    => 1,
        Digits  => 1,
        Tip     => 'Up and down',
        Frame   => 'frame1');

References

Gtk2-Perl HScrollbar, Gtk2-Perl VScrollbar, Gtk2 HScrollbar, Gtk2 VScrollbar

Available Support Functions

string = get_value (<name>, “Active” or “Min|Minimum” or “Max|Maximum” or “Step” or “Digits”)

set_value (<name>, Start => <start_value> or Active => <active_value> or Min => <min_value> or Max => <max_value> or Step => <step_in/decrease> or Digits => <used_digits>)

hide_widget (<name>)

show_widget (<name>)

(x_pos, y_pos) = get_pos (<name>)

set_pos (<name>, <new_x>, <new_y>)

state = is_sensitive (<name>)

set_sensitive (<name>, <state>)

string = get_tooltip (<name>)

set_tooltip (<name>, <tooltip_text>)

Miscellaneous

GtkDrawingArea

A widget for custom user interface elements.

add_drawing_area

sub add_drawing_area #(Name = > <name>,
Pos = > [pos_x, pos_y],
Size = > [width, height],
[Frame => <frame_name>],  
[Function => <function_click>],  
[Signal => <signal>],  
[Sensitive => <sensitive>]  )

Creates a new GtkImage widget.

The GtkDrawingArea widget is used for creating custom user interface elements.  It’s essentially a blank widget.  After creating a drawing area, the application may want to connect to:

  • Mouse and button press signals to respond to input from the user.  Use add_signal_handler for that.
  • The “realize” signal to take any necessary actions when the widget is instantiated on a particular display.  (Create GDK resources in response to this signal.)
  • The “configure_event” signal to take any necessary actions when the widget changes size.
  • The “expose_event” signal to handle redrawing the contents of the widget.

Internal Name Type

DrawingArea

Parameters

Name => <name>Name of the drawing area.  Must be unique.
Pos|Position => [pos_x, pos_y]Position of the drawing area.
Size => [width, height]Width and height of the drawing area.  Note: Gtk2 pixmaps have a current limit of short unsigned INT, highest pixels is 32767-1 (8bit int max).
[Frame => <frame_name>]Optional.  Name of the frame if the drawing area is located in one.  Must be unique.  See add_frame.
[Func|Function => <function_click>]Optional.  Function reference/sub.  Can be set later with add_signal_handlerNote: If data is used it have to be set as an array.
[Sig|Signal => <signal>]Optional.  The used action signal.  Only in conjunction with Func|Function.  Most used is ‘button_press_event’.
[Sens|Sensitive => <sensitive>]Optional.  Sets the drawing area active/inactive.  Default: 1 (active).

Returns

None.

Example

$win->add_drawing_area(Name => 'drawArea',
        Pos     => [10, 10],
        Size    => [$draw_surface[0], $draw_surface[1]]);
$win->add_signal_handler('drawArea', 'button_press_event', \&button_press_event);
$win->add_signal_handler('drawArea', 'button_release_event', \&button_release_event);
$win->add_signal_handler('drawArea', 'motion_notify_event', \&motion_notify_event);

References

Gtk2-Perl, Gtk2

Available Support Functions

initial_draw (<drawing_area_name>, <function>, [<data>])

string = get_value (<name>, “” or “”)

set_value (<name>, => <new_value>)

hide_widget (<name>)

show_widget (<name>)

(width, height) = get_size (<name>)

set_size (<name>, <new_width>, <new_height>)

(x_pos, y_pos) = get_pos (<name>)

set_pos (<name>, <new_x>, <new_y>)

state = is_sensitive (<name>)

set_sensitive (<name>, <state>)

initial_draw

sub initial_draw #(<drawing_area_name>,
<function>,
[<data>])

Base function to draw with the drawing area.

This base function is needed to draw in SimpleGtk2 because drawings need to initialize before Gtk2->main() is called.

Parameters

<drawing_area_name>Name of the drawing area.  Must be unique.
<function>Used custom draw function.
[<data>]Optional.  The data you wish to have passed to this function.

Returns

None.

Example

$win->initial_draw('drawArea', sub{&draw_rect($win->get_object('drawArea'), \@{$rects{$rect}[0]},$rects{$rect}[1]);});

GtkTooltip

Add tips to your widgets.

add_tooltip

sub add_tooltip #(<name>,
<text>)

Add a tooltip to a widget.

The tooltip text should be written in double quotes to support control characters.  Longer text can break with ‘\’ at the end for better overview.

Restriction

Not available for the following widgets: GtkMenu, GtkMenuBar, GtkFileChooserDialog, GtkFontSelectionDialog, GtkMessageDialog, GtkTreeView, GtkStatusbar, GtkTextView, GtkSeparator and GtkNotebook.

Parameters

<name>Name of a widget.  Must be unique.
<tooltip_text>Text of the tooltip

Returns

None.

Examples

$win->add_tooltip('image1', "This is a tooltip");
--------------------------------------
$win->add_tooltip('image1', "This is a longer tooltip text \
                             with a visual break to handle \
                             it nicer in the code.\nAlso line \
                             breaks can be added, too.");

get_tooltip

sub get_tooltip #(<name>)

Returns the current tooltip text of a widget.

Restriction

Not available for the following widgets: GtkMenu, GtkMenuBar, GtkFileChooserDialog, GtkFontSelectionDialog, GtkMessageDialog, GtkTreeView, GtkStatusbar, GtkTextView, GtkSeparator and GtkNotebook.

Parameters

<name>Name of a widget.

Returns

Tooltip text or undef.

Example

my $text = $win->get_tooltip('image1');

set_tooltip

sub set_tooltip #(<name>,
<tooltip_text>)

Sets a new tooltip text on a widget.

If no tooltip exists function will add it.

Restriction

Not available for the following widgets: GtkMenu, GtkMenuBar, GtkFileChooserDialog, GtkFontSelectionDialog, GtkMessageDialog, GtkTreeView, GtkStatusbar, GtkTextView, GtkSeparator and GtkNotebook.

Parameters

<name>Name of a widget.
<tooltip_text>Text of the tooltip

Returns

None.

Example

my $text = $win->set_tooltip('image1');
sub use_gettext #(<locale_paths>,
<translation_file>,
<codeset>)
Activate localization via gettext.
sub translate #(<text>)
Translation function used to translate text parts interrupted by variables.
sub internal_die #(<msg>)
Internal die function if a fatal error occurs.
sub show_error #(<msg>)
Print an error message to standard error.
sub show_message #(<msg>)
Print a message to standard error.
sub add_signal_handler #(<name>,
<signal>,
<function>,
[<data>])
Adds a signal handler to a widget.
sub remove_signal_handler #(<name>,
<signal>)
Removes a signal handler (signal-function pair) from a widget.
sub get_object #(<name|widget>)
Get the SimpleGtk2 widget hash from internal objects list.
sub exist_object #(<name|widget>)
Check function if SimpleGtk2 object xyz exists.
sub get_widget #(<name>)
Get a Gtk2 widget reference of a SimpleGtk2 object.
sub hide_widget #(<name>)
Hide a widget.
sub show_widget #(<name>)
Show a hidden widget.
sub is_sensitive #(<name>)
Returns the sensitive state of a widget.
sub set_sensitive #(<name|group>,
<state>)
Set sensitivity of a widget, a radio group or notebook page.
sub get_title #(<name>)
Returns the title text of a widget or the active value of a combo box.
sub set_title #(<name>,
<new_title>)
Sets the new title text of a widget or the active value of a combo box.
sub get_size #(<name>)
Returns the current width and height (in pixel) of a widget.
sub set_size #(<name>,
<new_width>,
<new_height>)
Sets the new size of a widget.
sub get_pos #(<name>)
Returns the current position (in pixel) of a widget.
sub set_pos #(<name>,
<new_x>,
<new_y>)
Sets the new position of a widget.
sub is_active #(<name>,
[<value/string>])
Returns the state of Check- and RadioButtons or for given combobox value/string.
sub is_underlined #(<text>)
Returns the state of a text whether it has an underline.
sub get_value #( <name>,  
 <keyname>,  
or <keyname> = > <value>)
Returns a current value of a widget.
sub set_value #(<name>,  
<keyname> = > <new_value>)
Sets a new value for a widget.
sub set_values #(<name>,  
<keyname> = > <new_value>,
<keyname> = > <new_value>,
...  )
Set a bunch of new values for a widget.
sub get_fontsize #(<name|widget>)
Returns the current font size of a widget.
sub get_fontfamily #(<name|widget>)
Returns the current font family of a widget.
sub get_fontweight #(<name|widget>)
Returns the current font weight of a widget.
sub get_font_string #(<name>)
Returns the current font string of a widget.
sub get_font_array #(<name>)
Returns current font string of a widget as an array.
sub font_array_to_string #(<font_array>)
Converts a font array into a font string.
sub font_string_to_array #(<font_string>)
Converts a font string into a font array.
sub set_font #( <name>,  
 <font_string>,  
or [family, size, [weight]],  
or Family = > <Family>,
 Size = > <Size>,
 Weight = > <Weight>)
Set new font of a widget.
sub set_font_color #(<name>,
<color>,
[<state>])
Set new font color of a widget.
sub new_window #(Name = > <name>,
Title = > <window title>,
[Version => <version-string>],  
[Base => <font_size>],  
[Size => [width, height]],  
[Fixed => <0/1>],  
[Iconpath => <icon_path>],  
[ThemeIcon => <theme_icon_name>],  
[Statusbar => <show_time|1>]  )
Creates a new GtkWindow, a toplevel window, that contain other widgets.
sub show #()
Show toplevel window with all widgets without running Gtk2->main
sub show_and_run #()
Show toplevel window with all widgets and start Gtk2->main.
sub add_msg_dialog #(Name = > <name>,
Modal = > <0/1>,
DType = > <dialog_type>,
MTyp = > <message_type>,
[Icon => <path|stock|name>],  
[RFunc => <response_function>]  )
Creates a new GtkMessageDialog object.
sub show_msg_dialog #( <name>,
 <message_text1>,
 <message_text2>,
or <dialog_type>,
 <message_type>,
 <message_text>)
Shows a standalone, simple or normal message dialog.
sub add_image #( Name = > <name>,
 Path = > <file_path>,
or Pixbuffer = > <pix_buffer_object>,
or Stock = > [<stock_name>[,<stock_size>]],
 Size = > [width, height],
 Position = > [pos_x, pos_y],
 [Frame => <frame_name>],  
 [Tooltip => <tooltip_text>],  
 [Function => <function_click>],  
 [Signal => <signal>],  
 [Sensitive => <sensitive>]  )
Creates a new GtkImage widget.
sub get_image #(<name>,
[<keyname>])
Returns the image reference, the pixbuffer or the path.
sub set_image #( Name = > <name>,
 Path = > <file_path>,
or Pixbuffer = > <pix_buffer_object>,
or Image = > <image_object>,
or Stock = > [<stock_name>, <stock_size>])
Sets a new image, stock icon, pixbuffer or file path.
sub add_label #(Name = > <name>,
Position = > [pos_x, pos_y],
Title = > <title>,
[Frame => <frame_name>],  
[Font => [family, size, weight]],  
[Widget => <name_of_linked_widget>],  
[Justify => <justify>],  
[Wrapped => <0/1>],  
[Tooltip => <tooltip_text>],  
[Sensitive => <sensitive>]  )
Creates a new GtkLabel widget.
sub add_statusbar #(Name = > <name>,
Position = > [pos_x, pos_y],
[Size => [width, height]],  
[Frame => <frame_name>],  
[Timeout => <show_time>],  
[Sensitive => <sensitive>]  )
Creates a new GtkStatusbar widget.
sub set_sb_text #([<name>],
<text>)
Sets/display a new status bar message.
sub remove_sb_text #([<name>],
[<text>|<msg-id>])
Removes a message from the status bar.
sub clear_sb_stack #(<name>)
Clears the message stack of a status bar.
sub add_button #(Name = > <name>,
Position = > [pos_x, pos_y],
Title = > <title>,
[Frame => <frame_name>],  
[Font => [family, size, weight]],  
[Color => [<color>, <state>]],  
[Size => [width, height]],  
[Tooltip => <tooltip_text>],  
[Function => <function_click>],  
[Signal => <signal>],  
[Sensitive => <sensitive>]  )
Creates a new GtkButton widget.
sub add_check_button #(Name = > <name>,
Position = > [pos_x, pos_y],
Title = > <title>,
[Frame => <frame_name>],  
[Active => <0/1>],  
[Font => [family, size, weight]],  
[Color => [<color>, <state>]],  
[Tooltip => <tooltip_text>],  
[Function => <function_click>],  
[Signal => <signal>],  
[Sensitive => <sensitive>]  )
Creates a new GtkCheckButton widget.
sub add_radio_button #(Name = > <name>,
Position = > [pos_x, pos_y],
Title = > <title>,
Group = > <button_group>,
[Frame => <frame_name>],  
[Active => <0/1>],  
[Font => [family, size, weight]],  
[Color => [<color>, <state>]],  
[Tooltip => <tooltip_text>],  
[Function => <function_click>],  
[Signal => <signal>],  
[Sensitive => <sensitive>]  )
Creates a new GtkRadioButton widget.
sub add_link_button #(Name = > <name>,
Position = > [pos_x, pos_y],
Title = > <title>,
Uri = > <uri-text>,
[Frame => <frame_name>],  
[Font => [family, size, weight]],  
[Color => [<color>, <state>]],  
[Size => [width, height]],  
[Function => <function_click>],  
[Signal => <signal>],  
[Sensitive => <sensitive>]  )
Creates a new GtkLinkButton widget.
sub add_entry #(Name = > <name>,
Position = > [pos_x, pos_y],
Size = > [width, height],
[Title => <title>],  
[Frame => <frame_name>],  
[Font => [family, size, weight]],  
[Align => <xalign>],  
[Tooltip => <tooltip_text>],  
[Function => <function_click>],  
[Signal => <signal>],  
[Sensitive => <sensitive>]  )
Creates a new GtkEntry widget.
sub add_slider #(Name = > <name>,
Position = > [pos_x, pos_y],
Orientation = > <orientation>,
[Size => [width, height]],  
[Start => <start_value>],  
Minimum = > <min_value>,
Maximum = > <max_value>,
Step = > <step_in/decrease>,
[DrawValue => <1/0>],  
[ValuePosition => <value_position>],  
[Digits => <used_digits>],  
[Frame => <frame_name>],  
[Tooltip => <tooltip_text>],  
[Function => <function_click>],  
[Signal => <signal>],  
[Sensitive => <sensitive>]  )
Creates a new GtkSlider widget.
sub add_spin_button #(Name = > <name>,
Position = > [pos_x, pos_y],
[Size => [width, height]],  
[Start => <start_value>],  
Minimum = > <min_value>,
Maximum = > <max_value>,
Step = > <step_in/decrease>,
Page = > <page_in/decrease>,
[Snap => <snap_to_tick>],  
[Align => <xalign>],  
[Rate => <from 0.0 to 1.0>],  
[Digits => <used_digits>],  
[Frame => <frame_name>],  
[Tooltip => <tooltip_text>],  
[Function => <function_click>],  
[Signal => <signal>],  
[Sensitive => <sensitive>]  )
Creates a new GtkSpinButton widget.
sub add_text_view #( Name = > <name>,
 Position = > [pos_x, pos_y],
 Size = > [width, height],
 Path = > <file_path>,
or Textbuffer = > <text_buffer_object>,
or Text = > <text_string>,
 [LeftMargin => <in_pixel>],  
 [RightMargin => <in_pixel>],  
 [Wrapped => <wrap_mode>],  
 [Justify => <justification>],  
 [Frame => <frame_name>],  
 [Tooltip => <tooltip_text>],  
 [Function => <function_click>],  
 [Signal => <signal>],  
 [Sensitive => <sensitive>]  )
Creates a new GtkTextView widget.
sub get_textview #(<name>,
[<keyname>])
Returns the textview reference, its’ textbuffer or the file path.
sub set_textview #( Name = > <name>,
 Path = > <file_path>,
or Textbuffer = > <text_buffer_object>,
or Text = > <text_string>)
Sets a new text, textbuffer or file path.
sub add_treeview #(Name = > <name>,
Type = > <List|Tree>,
Position = > [pos_x, pos_y],
Size = > [width, height],
Headers = > [<Array_of_column_pairs>],
[Data => [<Array_of_arrays>]],  
[Treeview => <Gtk2::TreeView>],  
[Mode => <selection mode>],  
[Frame => <frame_name>],  
[Function => <function_click>],  
[Signal => <signal>],  
[Sensitive => <sensitive>]  )
Creates a new GtkTreeView widget.
sub get_treeview #(<name>,
[<keyname>])
Returns the treeview reference.
sub add_combo_box #(Name = > <name>,
Position = > [pos_x, pos_y],
Data = > [Array_of_values>],
[Start => <start_value>],  
[Size => [width, height]],  
[Frame => <frame_name>],  
[Tooltip => <tooltip_text>],  
[Function => <function_click>],  
[Signal => <signal>],  
[Sensitive => <sensitive>]  )
Creates a new GtkComboBox widget.
sub add_menu_bar #(Name = > <name>,
Position = > [pos_x, pos_y],
[Size => [width, height]]  )
Creates a new GtkMenuBar widget.
sub add_menu #(Name = > <name>,
Menubar = > <menu_bar>,
Title = > <title>,
[Justify => <justification>],  
[Sensitive => <sensitive>]  )
Creates a new GtkMenu widget.
sub add_menu_item #(Name = > <name>,
Menu = > <menu_name>,
[Type => <type>],  
[Title => <title>],  
[Tip|Tooltip => <tooltip_text>],  
[Icon => <path|stock|name>],  
Group = > <group_name>,
Active = > <0/1>,
[Func|Function => <function>],  
[Sig|Signal => <signal>],  
[Sens|Sensitive => <sensitive>]  )
Creates a new GtkMenuItem widget.
sub add_filechooser_button #(
   Name = > <name>,
   Position = > [pos_x, pos_y],
   Title = > <title>,
   Action = > <open_mode>,
   [Frame => <frame_name>],  
   [File => <file_path>],  
   [Filter => <pattern|mimetype> | [<name>, <pattern|mimetype>]],  
   [Folder => <directory>],  
   [Size => [width, height]],  
   [Function => <function_click>],  
   [Signal => <signal>],  
   [Sensitive => <sensitive>]  
)
Creates a new GtkFileChooserButton widget.
sub add_filechooser_dialog #(
   Name = > <name>,
   Action = > <open_mode>,
   [Title => <title>],  
   [FName => <file_name>],  
   [Filter => <pattern|mimetype> | [<name>, <pattern|mimetype>]],  
   [Folder => <directory>],  
   [RFunc => <response_function>]  
)
Creates a new GtkFileChooserDialog widget.
sub show_filechooser_dialog #(
   <name>,
   <filename|file|folder>
), or (<action_type>, <filename|file|folder>, <pattern|mimetype>, or [<name>, <pattern|mimetype>])
Shows a simple or normal filechooser dialog.
sub add_font_button #(Name = > <name>,
Position = > [pos_x, pos_y],
Title = > <title>,
Action = > <open_mode>,
[Frame => <frame_name>],  
[Font => [family, size, weight]],  
[Size => [width, height]],  
[Function => <function_click>],  
[Signal => <signal>],  
[Sensitive => <sensitive>]  )
Creates a new GtkFontButton widget.
sub add_fontselection_dialog #(Name = > <name>,
Title = > <title>,
[Font => [family, size, weight]],  
[Preview => <preview text>],  
[RFunc => <response_function>]  )
Creates a new GtkFontSelectionDialog widget.
sub show_fontselection_dialog #(<name>) or (<family>, <size>, <weight>)
Shows simple or normal fontselection dialog.
sub add_notebook #(Name = > <name> ,
Pos|Position = > [pos_x, pos_y],
Size = > [width, height],
[Tabs => <position>],  
[Scroll|Scrollable => <0/1>],  
[Popup => <0/1>],  
[Frame => <frame_name>],  
[Sens|Sensitive => <sensitive>]  )
Creates a new GtkNotebook widget.
sub add_nb_page #(Name = > <name>,
Notebook = > <notebook_name>,
[Font => [family, size, weight]],  
[Color => [<color>, <state>]],  
[Pos_n|PositionNumber => <number>],  
[Tip|Tooltip => <tooltip_text>],  
[Sens|Sensitive => <sensitive>]  )
Creates a new GtkNotebook page.
sub remove_nb_page #(<nb_name>,
<title|number>)
Removes a notebook page from a notebook.
sub add_frame #(Name = > <name>,
Position = > [pos_x, pos_y],
[Title => <title>],  
[Frame => <frame_name>],  
[Font => [family, size, weight]],  
[Tooltip => <tooltip_text>],  
[Sensitive => <sensitive>]  )
Creates a new GtkFrame widget.
sub add_separator #(Name = > <name>,
Orient|Orientation = > <orientation>,
Pos|Position = > [pos_x, pos_y],
[Size => [width, height]],  
[Frame => <frame_name>],  
[Sens|Sensitive => <sensitive>]  )
Creates a new GtkSeparator widget.
sub add_scrollbar #(Name = > <name>,
Position = > [pos_x, pos_y],
Orientation = > <orientation>,
[Size => [width, height]],  
[Start => <start_value>],  
Minimum = > <min_value>,
Maximum = > <max_value>,
Step = > <step_value>,
[Digits => <used_digits>],  
[Frame => <frame_name>],  
[Tooltip => <tooltip_text>],  
[Function => <function_click>],  
[Signal => <signal>],  
[Sensitive => <sensitive>]  )
Creates a new GtkScrollBar widget.
sub add_drawing_area #(Name = > <name>,
Pos = > [pos_x, pos_y],
Size = > [width, height],
[Frame => <frame_name>],  
[Function => <function_click>],  
[Signal => <signal>],  
[Sensitive => <sensitive>]  )
Creates a new GtkImage widget.
sub initial_draw #(<drawing_area_name>,
<function>,
[<data>])
Base function to draw with the drawing area.
sub add_tooltip #(<name>,
<text>)
Add a tooltip to a widget.
sub get_tooltip #(<name>)
Returns the current tooltip text of a widget.
sub set_tooltip #(<name>,
<tooltip_text>)
Sets a new tooltip text on a widget.
A notebook page.
A menu widget.
The widget used for item in menus.
A standard menu bar.
A horizontal or vertical slider widget for selecting a value from a range.
A horizontal or vertical scrollbar.
A widget displaying an image.
Widget that displays a GtkTextBuffer.
A tabbed notebook container.
A widget that creates a discrete toggle button with label.
A choice from multiple check buttons.
A widget that displays a small to medium amount of text.
A file chooser dialog.
A dialog box for selecting fonts.
A convenient message window
A widget for displaying both trees and lists.
Report messages of minor importance to the user.
A horizontal or vertical separator.
Close