A Rapid Application Development Library for Gtk+ version 2.
SimpleGtk2 | A Rapid Application Development Library for Gtk+ version 2. |
Description | SimpleGtk2 is a wrapper library to build graphical user interfaces with a minimal programming effort. |
Example | The ‘Hello World’ example ;-) |
Basics | Short introduction how SimpleGtk2 is constructed. |
Special Feature | SimpleGtk2 has module support for FVWM to use it in conjunction with fvwm-perllib. |
Caveats | The problems and their handling. |
Bugs | Where to send bug reports. |
License | This software stands under the GPL V2 or higher. |
Author | © 2015 Thomas Funk t.f@web .de unk |
Thanks | |
Helpers | Helper functions to support things like localization, stderr messages, etc. |
Localization | |
use_gettext | Activate localization via gettext. |
translate | Translation function used to translate text parts interrupted by variables. |
Messages | |
internal_die | Internal die function if a fatal error occurs. |
show_error | Print an error message to standard error. |
show_message | Print a message to standard error. |
Support Functions | Common functions for signaling, object handling, etc. |
Signaling | |
add_signal_handler | Adds a signal handler to a widget. |
remove_signal_handler | Removes a signal handler (signal-function pair) from a widget. |
Object Handling | |
get_object | Get the SimpleGtk2 widget hash from internal objects list. |
exist_object | Check function if SimpleGtk2 object xyz exists. |
Widget Handling | |
get_widget | Get a Gtk2 widget reference of a SimpleGtk2 object. |
hide_widget | Hide a widget. |
show_widget | Show a hidden widget. |
is_sensitive | Returns the sensitive state of a widget. |
set_sensitive | Set sensitivity of a widget, a radio group or notebook page. |
get_title | Returns the title text of a widget or the active value of a combo box. |
set_title | Sets the new title text of a widget or the active value of a combo box. |
get_size | Returns the current width and height (in pixel) of a widget. |
set_size | Sets the new size of a widget. |
get_pos | Returns the current position (in pixel) of a widget. |
set_pos | Sets the new position of a widget. |
is_active | Returns the state of Check- and RadioButtons or for given combobox value/string. |
is_underlined | Returns the state of a text whether it has an underline. |
get_value | Returns a current value of a widget. |
set_value | Sets a new value for a widget. |
set_values | Set a bunch of new values for a widget. |
Font Handling | |
get_fontsize | Returns the current font size of a widget. |
get_fontfamily | Returns the current font family of a widget. |
get_fontweight | Returns the current font weight of a widget. |
get_font_string | Returns the current font string of a widget. |
get_font_array | Returns current font string of a widget as an array. |
font_array_to_string | Converts a font array into a font string. |
font_string_to_array | Converts a font string into a font array. |
set_font | Set new font of a widget. |
set_font_color | Set new font color of a widget. |
Windows | |
GtkWindow | Toplevel window which can contain other widgets |
new_window | Creates a new GtkWindow, a toplevel window, that contain other widgets. |
show | Show toplevel window with all widgets without running Gtk2->main |
show_and_run | Show toplevel window with all widgets and start Gtk2->main. |
GtkMessageDialog | A convenient message window |
add_msg_dialog | Creates a new GtkMessageDialog object. |
show_msg_dialog | Shows a standalone, simple or normal message dialog. |
Display Widgets | |
GtkImage | A widget displaying an image. |
add_image | Creates a new GtkImage widget. |
get_image | Returns the image reference, the pixbuffer or the path. |
set_image | Sets a new image, stock icon, pixbuffer or file path. |
GtkLabel | A widget that displays a small to medium amount of text. |
add_label | Creates a new GtkLabel widget. |
GtkStatusbar | Report messages of minor importance to the user. |
add_statusbar | Creates a new GtkStatusbar widget. |
set_sb_text | Sets/display a new status bar message. |
remove_sb_text | Removes a message from the status bar. |
clear_sb_stack | Clears the message stack of a status bar. |
Buttons and Toggles | |
GtkButton | A widget that creates a signal when clicked on. |
add_button | Creates a new GtkButton widget. |
GtkCheckButton | A widget that creates a discrete toggle button with label. |
add_check_button | Creates a new GtkCheckButton widget. |
GtkRadioButton | A choice from multiple check buttons. |
add_radio_button | Creates a new GtkRadioButton widget. |
GtkLinkButton | A button bound to an URL. |
add_link_button | Creates a new GtkLinkButton widget. |
Numeric/ | |
GtkEntry | A single line text entry field. |
add_entry | Creates a new GtkEntry widget. |
GtkSlider | A horizontal or vertical slider widget for selecting a value from a range. |
add_slider | Creates a new GtkSlider widget. |
GtkSpinButton | Retrieve an integer or floating-point number from the user. |
add_spin_button | Creates a new GtkSpinButton widget. |
Multiline Text Editor | |
GtkTextView | Widget that displays a GtkTextBuffer. |
add_text_view | Creates a new GtkTextView widget. |
get_textview | Returns the textview reference, its’ textbuffer or the file path. |
set_textview | Sets a new text, textbuffer or file path. |
Tree and List Widgets | |
GtkTreeView | A widget for displaying both trees and lists. |
add_treeview | Creates a new GtkTreeView widget. |
get_treeview | Returns the treeview reference. |
Combo Box and Menus | |
GtkComboBox | A widget used to choose from a list of items. |
add_combo_box | Creates a new GtkComboBox widget. |
GtkMenuBar | A standard menu bar. |
add_menu_bar | Creates a new GtkMenuBar widget. |
GtkMenu | A menu widget. |
add_menu | Creates a new GtkMenu widget. |
GtkMenuItem | The widget used for item in menus. |
add_menu_item | Creates a new GtkMenuItem widget. |
Selectors (File/ | |
GtkFileChooserButton | A button to launch a file selection dialog. |
add_filechooser_button | Creates a new GtkFileChooserButton widget. |
GtkFileChooserDialog | A file chooser dialog. |
add_filechooser_dialog | Creates a new GtkFileChooserDialog widget. |
show_filechooser_dialog | Shows a simple or normal filechooser dialog. |
GtkFontButton | A button to launch a font selection dialog. |
add_font_button | Creates a new GtkFontButton widget. |
GtkFontSelectionDialog | A dialog box for selecting fonts. |
add_fontselection_dialog | Creates a new GtkFontSelectionDialog widget. |
show_fontselection_dialog | Shows simple or normal fontselection dialog. |
Layout Containers | |
GtkNotebook | A tabbed notebook container. |
add_notebook | Creates a new GtkNotebook widget. |
GtkNotebookPage | A notebook page. |
add_nb_page | Creates a new GtkNotebook page. |
remove_nb_page | Removes a notebook page from a notebook. |
Ornaments | |
GtkFrame | A bin with a decorative frame and optional label. |
add_frame | Creates a new GtkFrame widget. |
GtkSeparator | A horizontal or vertical separator. |
add_separator | Creates a new GtkSeparator widget. |
Scrolling | |
GtkScrollBar | A horizontal or vertical scrollbar. |
add_scrollbar | Creates a new GtkScrollBar widget. |
Miscellaneous | |
GtkDrawingArea | A widget for custom user interface elements. |
add_drawing_area | Creates a new GtkImage widget. |
initial_draw | Base function to draw with the drawing area. |
GtkTooltip | Add tips to your widgets. |
add_tooltip | Add a tooltip to a widget. |
get_tooltip | Returns the current tooltip text of a widget. |
set_tooltip | Sets a new tooltip text on a widget. |
The ‘Hello World’ example ;-)
#! /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;
#! /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();
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.
SimpleGtk2 has module support for FVWM to use it in conjunction with fvwm-perllib. See <FVWM Support> for more information.
The problems and their handling.
GtkFixed has some caveats but the most annoying ones are removed or can be defanged with this library:
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.
Where to send bug reports.
Bug reports can be sent to fvwmnightshade-workers mailing list at https://groups.google.com
© 2015 Thomas Funk t.f@web .de unk
sub use_gettext #( <locale_paths>, <translation_file>, <codeset> )
Activate localization via gettext.
<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. |
None.
SimpleGtk2::use_gettext("fns-menu-configurator", "$ENV{FVWM_USERDIR}/locale:$ENV{FNS_SYSTEMDIR}/locale:+");
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.
<msg> | Die message printed to stderr. |
A die message before exiting the program.
$win->internal_die($object, "No action defined!");
[$win->$ExitButton]: No action defined! Exiting.
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.
<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. |
None.
$win->add_signal_handler('closeButton', 'clicked', sub{Gtk2->main_quit;}); -------------------------------------- $win->add_signal_handler('changeIconDir', 'clicked', \&change_path, [$win, 'entryIconDir']);
sub remove_signal_handler #( <name>, <signal> )
Removes a signal handler (signal-function pair) from a widget.
<name> | Name of the widget. Must be unique. |
<signal> | Signal which should removed from the widget. |
None.
$win->remove_signal_handler('closeButton', 'clicked'); -------------------------------------- $win->remove_signal_handler('changeIconDir', 'clicked');
sub get_object #( <name|widget> )
Get the SimpleGtk2 widget hash from internal objects list.
<name> | Name of a widget. Must be unique. OR |
<widget> | Reference object of a widget (e.g. Gtk2::Button). |
Object hash
# with name $win->get_object('NB_page' . $number)->{pagelabel}->set_sensitive($state); -------------------------------------- # with widget reference my $object_name = $win->get_object($widget)->{name};
sub get_widget #( <name> )
Get a Gtk2 widget reference of a SimpleGtk2 object.
Not available for the following widget: GtkNotebookPage.
<name> | Name of the widget. Must be unique. |
A Gtk2 widget reference.
$win->add_signal_handler('checkEnabled' . $name_number, 'toggled', sub {&on_checkbox_enabled_toggled($win->get_widget('comboResolution' . $name_number), $name);});
sub hide_widget #( <name> )
Hide a widget.
Not available for the following widgets: GtkMenu, GtkMenuItem, GtkMenuBar and GtkNotebookPage.
<name> | Name of the widget. Must be unique. |
None.
$win->add_signal_handler('image1', 'button_press_event', sub{$win->hide_widget('frame1');});
sub show_widget #( <name> )
Show a hidden widget.
Not available for the following widgets: GtkMenu, GtkMenuItem, GtkMenuBar and GtkNotebookPage.
<name> | Name of the widget. Must be unique. |
None.
$win->add_signal_handler('image1', 'button_press_event', sub{$win->show_widget('frame1');});
sub set_sensitive #( <name|group>, <state> )
Set sensitivity of a widget, a radio group or notebook page.
<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). |
None.
# deactivation of a radio group $win->set_sensitive('r_state', 0);
sub get_title #( <name> )
Returns the title text of a widget or the active value of a combo box.
Not available for the following widgets: GtkSlider, GtkScrollBar, GtkImage, GtkTextView, GtkMenuBar, GtkNotebook.
<name> | Name of the widget. Must be unique. |
The title text or undef.
# 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";
sub set_title #( <name>, <new_title> )
Sets the new title text of a widget or the active value of a combo box.
Not available for the following widgets: GtkSlider, GtkScrollBar, GtkImage, GtkTextView, GtkMenuBar, GtkNotebook.
<name> | Name of the widget. Must be unique. |
<new_title> | New title text for the widget or new active value for the combo box. |
None.
# 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");
sub get_size #( <name> )
Returns the current width and height (in pixel) of a widget.
Not available for the following widgets: GtkMenu, GtkMenuItem, GtkNotebookPage.
<name> | Name of the widget. Must be unique. |
An array of the current width and height or undef.
my ($width, $height) = $win->get_size('Image1');
sub set_size #( <name>, <new_width>, <new_height> )
Sets the new size of a widget.
Not available for the following widgets: GtkCheckButton, GtkRadioButton, GtkLabel, GtkMenu, GtkMenuItem, GtkNotebookPage.
<name> | Name of the widget. Must be unique. |
<new_width> | New width of the widget. |
<new_height> | New height of the widget. |
None.
$win->set_size('image1', 200, 100);
sub get_pos #( <name> )
Returns the current position (in pixel) of a widget.
Not available for the following widgets: GtkMenu, GtkMenuItem, GtkNotebookPage.
<name> | Name of the widget. Must be unique. |
An array of the current x and y position or undef.
my ($pos_x, $pos_y) = $win->get_pos('cbox1');
sub set_pos #( <name>, <new_x>, <new_y> )
Sets the new position of a widget.
Not available for the following widgets: GtkMenu, GtkMenuItem, GtkNotebookPage.
<name> | Name of the widget. Must be unique. |
<new_x> | New x-position of the widget. |
<new_y> | New y-position of the widget. |
None.
$win->set_pos('check_button', 10, 45);
sub is_active #( <name>, [<value/string>] )
Returns the state of Check- and RadioButtons or for given combobox value/string.
<name> | Name of the widget. Must be unique. |
<value/string> | A given combobox value/string. |
An array of the current x and y position or undef.
my ($pos_x, $pos_y) = $win->get_pos('cbox1');
sub get_value #( <name>, <keyname>, or <keyname> = > <value> )
Returns a current value of a widget.
<name> | Name of a widget. |
<keyname> | Keyword of a value. OR |
<keyname> => <value> | Nth value of the keyword array|hash. |
”Active” | The current state of the check button. |
”Active” | The current state of the radio button. |
”Group” | The current group object/reference. |
”Groupname|Gname” | The current group name (string). |
”Uri” | The current uri of the link button. |
”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. |
”Wrap|Wrapped” | Returns whether lines in the label are automatically wrapped. |
”Justify” | The current justification of the label. |
”Align” | The current alignment string of the entry. |
”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. |
”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. |
”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. |
”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. |
”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.
”Justify” | The current justification of the menu. |
”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). |
”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”. |
”PageNumber” | The page number of the notebook page. |
”Notebook” | The name of the notebook. |
”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”). |
”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”). |
”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. |
”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. |
”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. |
The found value.
if ($win->get_value("comboMaxFreq" . $a, "active") != $win->get_value("comboMaxFreqCommon", "active")) { ... } -------------------------------------- my $rowref = $window->get_value("slist", path => $index);
sub set_value #( <name>, <keyname> = > <new_value> )
Sets a new value for a widget.
<name> | Name of a widget. |
<keyname> => <new_value> | Keyword of a value and its new value. |
Active => <0/1> | The new state of the check button. 0 (deactivated) or 1 (activated). |
Active => <0/1> | The new state of the radio button. 0 (deactivated) or 1 (activated). |
Uri => <uri-text> | The new uri of the link button. |
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. |
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, |
Align => <xalign> | The new alignment of the entry: left or right. |
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. |
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. |
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. |
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. |
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.
Justify => <justification> | The new justification of the menu. |
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. |
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. |
Reorder => <0/1> | Sets the notebook page to a new position. |
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. |
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. |
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. |
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. |
None.
$win->set_value('NB1', Currentpage => $win->get_value('NB1', Title2number => $out)); -------------------------------------- $spin_button->set_value($cell->get("value"));
sub set_values #( <name>, <keyname> = > <new_value>, <keyname> = > <new_value>, ... )
Set a bunch of new values for a widget.
<name> | Name of a widget. |
<keyname> | Keyword of a value and its new value. |
See set_value for possible keynames.
None.
$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);
sub font_array_to_string #( <font_array> )
Converts a font array into a font string.
<font_array> | Font as an array like [family, size[, weight]]. Font family AND size is required. |
A font string.
my @fontarray = (Sans, 12); my $fontstring = font_array_to_string(@fontarray);
sub font_string_to_array #( <font_string> )
Converts a font string into a font array.
<font_string> | Font string. Font family AND size is required. |
A font array [family, size[, weight]].
my @fontarray = font_string_to_array('Arial Rounded MT Bold, Bold Italic 12');
sub set_font #( <name>, <font_string>, or [family, size, [weight]], or Family = > <Family>, Size = > <Size>, Weight = > <Weight> )
Set new font of a widget.
<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. |
None.
$win->set_font('frame1', Family => 'Bernard MT Condensed');
sub set_font_color #( <name>, <color>, [<state>] )
Set new font color of a widget.
<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 |
None.
$win->set_font_color('checkButton1','red'); -------------------------------------- $win->set_font_color('label1', '#8B008B');
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.
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. |
The main window object.
my $win = SimpleGtk2->new_window(Name => 'mainWindow', Title => 'testem-all', Size => [400, 400], ThemeIcon => 'emblem-dropbox-syncing');
show ()
show_and_run ()
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.
MessageDialog
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’. |
None.
# 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);
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. |
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.
<name> | Name of the message dialog. Must be unique. |
<message_text1> | The main message text. |
[<message_text2>] | Optional. A second text |
<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. |
The response. Can be “ok”, “close”, “cancel”, “yes”, “no” depending on the dialog type.
# 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);
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.
Image
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_handler. Note: 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). |
None.
# 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);
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>)
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.
<name> | Name of the image. Must be unique. |
<keyname> | Optional. Possible keynames are: ‘Path’, ‘Image’ or ‘Pixbuf|Pixbuffer’. |
The image reference, the pixbuffer or the path.
# get the pixbuffer my $pixbuff = $win->get_image('Image1', 'Pixbuf'); -------------------------------------- # get path of the picture my $file_path = $win->get_image('Image1', '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.
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. |
None.
# set a new image by path $win->set_image('Image1', Path => '/usr/share/icons/gnome/256x256/actions/appointment-new');
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.
Label
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). |
None.
$win->add_label(Name => 'label1', Pos => [10, 20], Title => "A Label.\n"."A new line", Justify => 'left');
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>)
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.
Statusbar
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). |
None.
$win->add_statusbar(Name => 'sbar1', Pos => [0, 0], Timeout => 2000);
The main window supports a statusbar at the bottom, too. See new_window for more details.
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>)
sub set_sb_text #( [<name>], <text> )
Sets/display a new status bar message.
<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. |
Message id.
$win->set_sb_text('sbar1', $text);
sub remove_sb_text #( [<name>], [<text>|<msg-id>] )
Removes a message from the status bar.
<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. |
None.
$win->remove_sb_text('sbar1', $msg_id[3]);
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.
Button
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_handler. Note: 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). |
None.
$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;});
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>)
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.
CheckButton
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_handler. Note: 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). |
None.
$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']);
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>)
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.
RadioButton
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_handler. Note: 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). |
None.
# 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');
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>)
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.
LinkButton
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_handler. Note: 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). |
None.
$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')]);
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>)
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.
Entry
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_handler. Note: 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). |
None.
$win->add_entry(Name => 'entry1', Pos => [200, 20], Size => [100, 20], Title => 'A text entry field', Align => 'right');
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>)
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.
Slider
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_handler. Note: 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). |
None.
$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');
Gtk2-Perl HScale, Gtk2-Perl VScale, Gtk2 HScale, Gtk2 VScale
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>)
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.
SpinButton
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_handler. Note: 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). |
None.
$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');
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>)
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.
TextView
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_handler. Note: 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). |
None.
# 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);
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>)
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.
<name> | Name of the textview widget. Must be unique. |
[<keyname>] | Optional. Possible values: Path, Textview, Textbuf”|”Textbuffer. |
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.
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. |
None.
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.
List or Tree
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_handler. Note: 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). |
text | Normal text strings. |
int | Integer values. |
double | Double-precision floating point values. |
bool | Boolean values, displayed as toggle-able checkboxes. |
scalar | A perl scalar, displayed as a text string by default. |
pixbuf | A Gtk2::Gdk::Pixbuf. |
None.
# 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);
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>)
value = get_value (<name>, “Editable” or “Path” or “Cell”)
set_value (<name>, select => <row|[row_list]> or unselect => <row|[row_list]>)
value = get_value (<name>, “Iter” or “Path” or “Row”)
set_value (<name>, iter => <iter> or path => <path_object> or row => [row_values])
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.
ComboBox
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_handler. Note: 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). |
None.
$win->add_combo_box(Name => 'combo1', Pos => [100, 60], Data => ['one', 'two', 'three', 'four'], Start => 1, Tip => 'Jup', Frame => 'frame1');
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>)
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.
MenuBar
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. |
None.
$win->add_menu_bar(Name => 'menubar1', Pos => [0,0]);
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>)
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.
Menu
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). |
None.
# menu Edit $win->add_menu(Name => 'menu_edit', Title => '_Edit', Menubar => 'menubar1');
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>)
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.
MenuItem, TearOffMenuItem, SeparatorMenuItem, RadioMenuItem or CheckMenuItem
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_handler. Note: 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). |
None.
# 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');
Gtk2-Perl MenuItem, RadioMenuItem, CheckMenuItem, SeparatorMenuItem, TearoffMenuItem
Gtk2 MenuItem, RadioMenuItem, CheckMenuItem, SeparatorMenuItem, TearoffMenuItem
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>)
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.
FileChooserButton
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_handler. Note: 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). |
None.
# 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']);
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>)
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.
FileChooserDialog
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. |
The chosen path/folder or 0.
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);
response = show_filechooser_dialog (<name>, <filename|file|folder>)
string = get_value (<name>, )
set_value ()
string = get_title (<name>)
set_title (<name>, <text>)
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.
<name> | Name of the filechooser dialog. Must be unique. |
<filename|file|folder> | The filename or file path or folder. |
<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. |
The chosen path/folder or 0.
# 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);
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.
FontButton
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_handler. Note: 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). |
None.
$window->add_font_button(Name => 'font_button', Pos => [20, 40], Font => ["Arial", 12]);
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>)
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.
FontSelectionDialog
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. |
The font string: “fontname weight size” or 0.
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>)
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.
<name> | Name of the fontselection dialog. Must be unique. |
<family> | The initial font family. |
<size> | The initial font size. |
<weight> | The initial font weight. |
The font string: “fontname weight size” or 0.
# A simple fontselection dialog -------------------------------------- # A 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.
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.
Notebook
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). |
None.
$win->add_notebook(Name => 'NB1', Pos => [10, 10], Size => [200, 200], Tabs => 'top', Popup => 1);
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>)
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.
NotebookPage
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). |
None.
$win->add_nb_page(Name => "NB_page1", Pos_n => 0, Title => "Page 1", Notebook => 'NB1', Tip => "This is the first page");
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>)
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.
Frame
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. |
None.
$win->add_frame(Name => 'frame1', Pos => [5, 5], Size => [390, 190], Title => ' A Frame around ');
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>)
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.
Separator
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). |
None.
Gtk2-Perl GtkHSeparator, Gtk2-Perl GtkVSeparator, Gtk2 GtkHSeparator Gtk2 GtkVSeparator
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>)
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.
Scrollbar
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_handler. Note: 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). |
None.
# 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');
Gtk2-Perl HScrollbar, Gtk2-Perl VScrollbar, Gtk2 HScrollbar, Gtk2 VScrollbar
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>)
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:
DrawingArea
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_handler. Note: 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). |
None.
$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);
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>)
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.
<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. |
None.
$win->initial_draw('drawArea', sub{&draw_rect($win->get_object('drawArea'), \@{$rects{$rect}[0]},$rects{$rect}[1]);});
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.
Not available for the following widgets: GtkMenu, GtkMenuBar, GtkFileChooserDialog, GtkFontSelectionDialog, GtkMessageDialog, GtkTreeView, GtkStatusbar, GtkTextView, GtkSeparator and GtkNotebook.
<name> | Name of a widget. Must be unique. |
<tooltip_text> | Text of the tooltip |
None.
$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.");
sub get_tooltip #( <name> )
Returns the current tooltip text of a widget.
Not available for the following widgets: GtkMenu, GtkMenuBar, GtkFileChooserDialog, GtkFontSelectionDialog, GtkMessageDialog, GtkTreeView, GtkStatusbar, GtkTextView, GtkSeparator and GtkNotebook.
<name> | Name of a widget. |
Tooltip text or undef.
my $text = $win->get_tooltip('image1');
sub set_tooltip #( <name>, <tooltip_text> )
Sets a new tooltip text on a widget.
If no tooltip exists function will add it.
Not available for the following widgets: GtkMenu, GtkMenuBar, GtkFileChooserDialog, GtkFontSelectionDialog, GtkMessageDialog, GtkTreeView, GtkStatusbar, GtkTextView, GtkSeparator and GtkNotebook.
<name> | Name of a widget. |
<tooltip_text> | Text of the tooltip |
None.
my $text = $win->set_tooltip('image1');
Activate localization via gettext.
sub use_gettext #( <locale_paths>, <translation_file>, <codeset> )
Translation function used to translate text parts interrupted by variables.
sub translate #( <text> )
Internal die function if a fatal error occurs.
sub internal_die #( <msg> )
Print an error message to standard error.
sub show_error #( <msg> )
Print a message to standard error.
sub show_message #( <msg> )
Adds a signal handler to a widget.
sub add_signal_handler #( <name>, <signal>, <function>, [<data>] )
Removes a signal handler (signal-function pair) from a widget.
sub remove_signal_handler #( <name>, <signal> )
Get the SimpleGtk2 widget hash from internal objects list.
sub get_object #( <name|widget> )
Check function if SimpleGtk2 object xyz exists.
sub exist_object #( <name|widget> )
Get a Gtk2 widget reference of a SimpleGtk2 object.
sub get_widget #( <name> )
Hide a widget.
sub hide_widget #( <name> )
Show a hidden widget.
sub show_widget #( <name> )
Returns the sensitive state of a widget.
sub is_sensitive #( <name> )
Set sensitivity of a widget, a radio group or notebook page.
sub set_sensitive #( <name|group>, <state> )
Returns the title text of a widget or the active value of a combo box.
sub get_title #( <name> )
Sets the new title text of a widget or the active value of a combo box.
sub set_title #( <name>, <new_title> )
Returns the current width and height (in pixel) of a widget.
sub get_size #( <name> )
Sets the new size of a widget.
sub set_size #( <name>, <new_width>, <new_height> )
Returns the current position (in pixel) of a widget.
sub get_pos #( <name> )
Sets the new position of a widget.
sub set_pos #( <name>, <new_x>, <new_y> )
Returns the state of Check- and RadioButtons or for given combobox value/string.
sub is_active #( <name>, [<value/string>] )
Returns the state of a text whether it has an underline.
sub is_underlined #( <text> )
Returns a current value of a widget.
sub get_value #( <name>, <keyname>, or <keyname> = > <value> )
Sets a new value for a widget.
sub set_value #( <name>, <keyname> = > <new_value> )
Set a bunch of new values for a widget.
sub set_values #( <name>, <keyname> = > <new_value>, <keyname> = > <new_value>, ... )
Returns the current font size of a widget.
sub get_fontsize #( <name|widget> )
Returns the current font family of a widget.
sub get_fontfamily #( <name|widget> )
Returns the current font weight of a widget.
sub get_fontweight #( <name|widget> )
Returns the current font string of a widget.
sub get_font_string #( <name> )
Returns current font string of a widget as an array.
sub get_font_array #( <name> )
Converts a font array into a font string.
sub font_array_to_string #( <font_array> )
Converts a font string into a font array.
sub font_string_to_array #( <font_string> )
Set new font of a widget.
sub set_font #( <name>, <font_string>, or [family, size, [weight]], or Family = > <Family>, Size = > <Size>, Weight = > <Weight> )
Set new font color of a widget.
sub set_font_color #( <name>, <color>, [<state>] )
Creates a new GtkWindow, a toplevel window, that contain other widgets.
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>] )
Show toplevel window with all widgets without running Gtk2->main
sub show #()
Show toplevel window with all widgets and start Gtk2->main.
sub show_and_run #()
Creates a new GtkMessageDialog object.
sub add_msg_dialog #( Name = > <name>, Modal = > <0/1>, DType = > <dialog_type>, MTyp = > <message_type>, [Icon => <path|stock|name>], [RFunc => <response_function>] )
Shows a standalone, simple or normal message dialog.
sub show_msg_dialog #( <name>, <message_text1>, <message_text2>, or <dialog_type>, <message_type>, <message_text> )
Creates a new GtkImage widget.
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>] )
Returns the image reference, the pixbuffer or the path.
sub get_image #( <name>, [<keyname>] )
Sets a new image, stock icon, pixbuffer or file path.
sub set_image #( Name = > <name>, Path = > <file_path>, or Pixbuffer = > <pix_buffer_object>, or Image = > <image_object>, or Stock = > [<stock_name>, <stock_size>] )
Creates a new GtkLabel widget.
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 GtkStatusbar widget.
sub add_statusbar #( Name = > <name>, Position = > [pos_x, pos_y], [Size => [width, height]], [Frame => <frame_name>], [Timeout => <show_time>], [Sensitive => <sensitive>] )
Sets/display a new status bar message.
sub set_sb_text #( [<name>], <text> )
Removes a message from the status bar.
sub remove_sb_text #( [<name>], [<text>|<msg-id>] )
Clears the message stack of a status bar.
sub clear_sb_stack #( <name> )
Creates a new GtkButton widget.
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 GtkCheckButton 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 GtkRadioButton 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 GtkLinkButton 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 GtkEntry 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 GtkSlider 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 GtkSpinButton 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 GtkTextView 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>] )
Returns the textview reference, its’ textbuffer or the file path.
sub get_textview #( <name>, [<keyname>] )
Sets a new text, textbuffer or file path.
sub set_textview #( Name = > <name>, Path = > <file_path>, or Textbuffer = > <text_buffer_object>, or Text = > <text_string> )
Creates a new GtkTreeView widget.
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>] )
Returns the treeview reference.
sub get_treeview #( <name>, [<keyname>] )
Creates a new GtkComboBox widget.
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 GtkMenuBar widget.
sub add_menu_bar #( Name = > <name>, Position = > [pos_x, pos_y], [Size => [width, height]] )
Creates a new GtkMenu widget.
sub add_menu #( Name = > <name>, Menubar = > <menu_bar>, Title = > <title>, [Justify => <justification>], [Sensitive => <sensitive>] )
Creates a new GtkMenuItem 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 GtkFileChooserButton 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 GtkFileChooserDialog 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>] )
Shows a simple or normal filechooser dialog.
sub show_filechooser_dialog #( <name>, <filename|file|folder> ), or (<action_type>, <filename|file|folder>, <pattern|mimetype>, or [<name>, <pattern|mimetype>])
Creates a new GtkFontButton widget.
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 GtkFontSelectionDialog widget.
sub add_fontselection_dialog #( Name = > <name>, Title = > <title>, [Font => [family, size, weight]], [Preview => <preview text>], [RFunc => <response_function>] )
Shows simple or normal fontselection dialog.
sub show_fontselection_dialog #( <name> ) or (<family>, <size>, <weight>)
Creates a new GtkNotebook widget.
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 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>] )
Removes a notebook page from a notebook.
sub remove_nb_page #( <nb_name>, <title|number> )
Creates a new GtkFrame widget.
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 GtkSeparator 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 GtkScrollBar 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 GtkImage 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>] )
Base function to draw with the drawing area.
sub initial_draw #( <drawing_area_name>, <function>, [<data>] )
Add a tooltip to a widget.
sub add_tooltip #( <name>, <text> )
Returns the current tooltip text of a widget.
sub get_tooltip #( <name> )
Sets a new tooltip text on a widget.
sub set_tooltip #( <name>, <tooltip_text> )