Gtk2::E...::Layout(3)
π Gtk2::E...::Layout β bestie edition π
okay so this is the manual page for Gtk2::Ex::FormFactory::Layout, straight out of the User Contributed Perl Documentation, and I'm gonna walk you through it like we're texting at 2am. it's giving layout queen. let's go π«Ά
β¨ NAME β¨
Gtk2::Ex::FormFactory::Layout β literally just: do layout in a FormFactory framework. that's the whole vibe. it lays stuff out. π
πΈ SYNOPSIS πΈ
here's how you'd actually roll your own:
package My::Layout;
use base qw/Gtk2::Ex::FormFactory::Layout/;
sub build_form { ... }
sub add_widget_to_form { ... }
...
package main;
$ff = Gtk2::Ex::FormFactory->new (
layouter => My::Layout->new(),
...
);
subclass it, drop it in as your layouter, done. iconic. β¨
π¦ DESCRIPTION π¦
so this class implements the layout of Containers and their Widgets in a Gtk2::Ex::FormFactory framework. and "Layout" here means everything: how are the widgets aligned to each other, how much space is between them, how are titles rendered, how labels, etc. the whole aesthetic, basically. π
the idea behind Gtk2::Ex::FormFactory::Layout is to have a unique point in a GUI application which actually implements these things. and the advantage of this approach is obvious, bestie: the implementation is very generic and if you want to change layout things you subclass from Gtk2::Ex::FormFactory::Layout and implement your changes there, and not at hundreds of spots distributed over the source code of your application. like, no more copy-paste chaos, no more "where did I set that padding". periodt.
the natural result: a consistent looking GUI. π
π SUBCLASSING π
as described above, implementing your own layout module starts with subclassing from Gtk2::Ex::FormFactory::Layout. to use your layout implementation set an object of your class as layouter in your Gtk2::Ex::FormFactory objects.
Gtk2::Ex::FormFactory::Layout mainly defines two sorts of methods. two. iconic duo energy. π―
π₯ BUILD METHODS
the names of the methods are derived from the Widget's short names (which can be retrieved with $widget->get_type), with a prepended build_, e.g.:
build_form ( ... )
build_label ( ... )
build_table ( ... )
the method prototype looks like this:
$layout->build_TYPE ($widget)β$widgetis the actualGtk2::Ex::FormFactory::Widget, e.g.Gtk2::Ex::FormFactory::Formforbuild_form($form).
the build_TYPE method actually creates the necessary Gtk2 widgets, e.g. a Gtk2::Table for a Gtk2::Ex::FormFactory::Form and adds these to the FormFactory's widget instance using the set_gtk_widget() and set_gtk_parent_widget() methods of Gtk2::Ex::FormFactory::Widget.
call $widget->set_gtk_widget($gtk_widget) for the primary Gtk2 widget which directly displays the value in question, e.g. a Gtk2::Entry if you're dealing with a Gtk2::Ex::FormFactory::Entry.
if you like to do more layout things which require to add the primary Gtk2 widget to a container, e.g. a Gtk2::Frame, you must call $widget->set_gtk_parent_widget($gtk_parent_widget) with the most top level container widget.
note: the implemenations of all the FormFactory's widgets expect a specificgtk_widgetto be set. if you like to change the primary Gtk widget you need to create your ownGtk2::Ex::FormFactory::Widgetfor this, because the default implemention most probably won't work with a anotherGtk2::Widget. β οΈ like, don't just swap it and hope. she will not cooperate.
π ADD...TO... METHODS
the second type of methods are so called add-to methods, which place a widget inside a container. the prototye is as follows:
$layout->add_TYPE_to_TYPE ($widget, $container)β$widgetis the actualGtk2::Ex::FormFactory::Widget, e.g.Gtk2::Ex::FormFactory::Formforbuild_form($form).
examples:
add_form_to_window ( ... )
add_table_to_form ( ... )
this way you can adjust layout at a very detailed level, but you need not. e.g. the implementation of these methods is most likely the same:
add_entry_to_form ( ... )
add_popup_to_form ( ... )
because the implemenation mainly depends on the form (the container widget) and not on the widget which is added to the form. π‘
that's why Gtk2::Ex::FormFactory::Layout knows a default mechanism: if no add-to method is found for a specific widget/container pair, a generic default implementation is used instead. these are named as follows:
add_widget_to_window ( ... )
add_widget_to_form ( ... )
add_widget_to_table ( ... )
add_widget_to_vbox ( ... )
...
for a new Container you just need to implement the generic add_widget_to_TYPE method, and everything will work. if you want to slightly modify the implementation for specific child widgets, you implement only the methods for these and you're done. slay. β¨
for a example for such a specific add-to message refer to add_menu_to_window() which attaches the menu without any space around it. the default of a Gtk2::Ex::FormFactory::Window is to have some spacing, which looks ugly around a menu. π (fr fr, menus with random padding are a crime)
π OBJECT HIERARCHY π
Gtk2::Ex::FormFactory::Layout
just the one. she stands alone. main character energy. π
β ATTRIBUTES β
this class has not attributes. not one. zero. clean girl aesthetic. π§
π AUTHORS π
JΓΆrn Reder <joern at zyn dot de>
π COPYRIGHT AND LICENSE π
copyright 2004-2006 by JΓΆrn Reder.
this library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
this library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. see the GNU Library General Public License for more details.
you should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA.
π POD ERRORS π
hey! the above document had some coding errors, which are explained below:
around line 1275:
Non-ASCII character seen before =encoding in 'JΓΆrn'. Assuming UTF-8
likeβ¦ the ΓΆ said "I'm here and I'm UTF-8, deal with it." π iconic honestly.
and that's the whole page, bestie!! this one came from the User Contributed Perl Documentation, perl v5.42.0, dated 2025-07-25 β mwah, go forth and lay out your widgets consistently πβ¨π¦
π¦ where this page comes from
- fedora 43: perl-Gtk2-Ex-FormFactory 0.67-39.fc43 Β· LicenseRef-Callaway-LGPLv2+
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms