Gtk2::E...mFactory(3)
π Gtk2::Ex::FormFactory β the perl manual, but make it make sense π
okay bestie, so this is the Gtk2::Ex::FormFactory manpage from the User Contributed Perl Documentation section of the manual. yes it's giving big-framework energy. yes you're gonna understand it. let's go π¦
β¨ NAME β¨
Gtk2::Ex::FormFactory β Makes building complex GUI's easy π
πΈ SYNOPSIS πΈ
#-- Refer to http://www.exit1.org/ for
#-- a comprehensive online documentation.
#-- Read Gtk2::Ex::FormFactory::Intro
use Gtk2::Ex::FormFactory;
my $context = Gtk2::Ex::FormFactory::Context->new;
$context->add_object (
name => "worksheet",
object => My::Worksheet->new,
);
# derived from Gtk2::Ex::FormFactory::Layout
my $layouter = My::Layout->new;
# derived from Gtk2::Ex::FormFactory::Rules
my $rule_checker = My::Rules->new;
my $ff = Gtk2::Ex::FormFactory->new (
context => $context,
layouter => $layouter,
rule_checker => $rule_checker,
content => [
Gtk2::Ex::FormFactory::Window->new (
title => "Worksheet Editor",
content => [
Gtk2::Ex::FormFactory::Form->new (
title => "Main data",
content => [
Gtk2::Ex::FormFactory::Entry->new (
label => "Worksheet title",
attr => "worksheet.title",
tip => "Title of this worksheet",
),
#-- More widgets...
],
),
Gtk2::Ex::FormFactory->DialogButtons->new,
],
),
],
);
$ff->open;
$ff->update;
Gtk2->main;
like, look at that. you just declared a whole GUI. no cap. π₯
π ABSTRACT π
With Gtk2::Ex::FormFactory you can build a GUI which consistently represents the data of your application. periodt. β¨
π DESCRIPTION π
okay so here's the whole vibe: this is a framework that tries to make building complex GUI's easy, and it does that with these two main features:
- Consistent looking GUI without the need to code resp. tune each widget by hand. Instead you declare the structure of your GUI, connect it to the data of your program (which should be a well defined set of objects) and control how this structure is transformed into a specific layout in a very generic way.
- Automatically keep widget and object states in sync (in both directions), even with complex data structures with a lot of internal dependencies, object nesting etc.
bestie, that second bullet? that's the one. two-way sync with deeply nested object graphs. it's giving magic. πͺ
This manpage describes the facilities of Gtk2::Ex::FormFactory objects which are only a small part of the whole framework. To get a full introduction and overview of how this framework works refer to Gtk2::Ex::FormFactory::Intro. (fr fr, go read that one, this page is just one slice of the cake π)
π OBJECT HIERARCHY π
Gtk2::Ex::FormFactory::Widget
+--- Gtk2::Ex::FormFactory::Container
+--- Gtk2::Ex::FormFactory
so Gtk2::Ex::FormFactory is a Container, which is a Widget. the family tree is real. π
β ATTRIBUTES β
Attributes are handled through the common get_ATTR(), set_ATTR() style accessors, but they are mostly passed once to the object constructor and must not be altered after the associated FormFactory was built. (so like β set them at birth, don't be messing with them later, okay? π)
context = Gtk2::Ex::FormFactory::Context[optional] β This is the Context of this FormFactory. The Context connects your application objects and their attributes with the GUI build through the FormFactory. Refer toGtk2::Ex::FormFactory::Contextfor details.
If you omit this option in the new() object constructor an empty Context is created which can be accessed with get_context.
layouter = Gtk2::Ex::FormFactory::Layout[optional] β This is the Layout module of this FormFactory. The Layout module actually builds the GUI and thus controls all details of appearance. Refer toGtk2::Ex::FormFactory::Layoutfor details, if you're interested in writing your own Layout module.
If you omit this option in the new() object constructor a default Gtk2::Ex::FormFactory::Layout object is created which can be accessed with get_layouter.
rule_checker = Gtk2::Ex::FormFactory::Rules[optional] β This is the rule checker module of this FormFactory. It's responsible to check user input against a set of rules which may be associated with a widget.
Refer to Gtk2::Ex::FormFactory::Rules for details, if you're interested in writing your own rule checker module.
If you omit this option in the new() object constructor a default Gtk2::Ex::FormFactory::Rules object is created which can be accessed with get_rule_checker.
sync = BOOL[optional] β By default all changes on the GUI trigger corresopndent updates on your application objects immediately. If you want to build dialogs with local changes on the GUI only, e.g. to be able to implement a Cancel button in a simple fashion (refer toGtk2::Ex::FormFactory::DialogButtons), you may switch this synchronisation off by settingsynctoFALSE.
π¨ okay heads up bestie, this one matters: asynchronous dialogs are static. Dependencies between objects and attributes, which are defined in the associatedGtk2::Ex::FormFactory::Context, don't work on widget/GUI level. That's why automatic dependency resolution / widget updating only works for FormFactory's withsyncset toTRUE. so like, you turn sync off, you lose the auto-magic. your call. π
parent_ff = Gtk2::Ex::FormFactoryobject [optional] β You may specify a parentGtk2::Ex::FormFactoryobject. The Gtk Window of this FormFactory will be set transient to the Gtk Window of the parent FormFactory. (it's a whole parent-child thing, the window knows who its mom is π )
π METHODS π
$form_factory->open ( [ hide => BOOL ])
This actually builds and displays the GUI, if you set the hide parameter to a true value. Until this method is called you can add new or modify existent Widgets of this FormFactory.
If you set hide you need to call $form_factory->show later, otherwise all widgets will keep invisible.
No object data will be transfered to the GUI, so it will be more or less empty. Call update to put data into the GUI. (so open is the bones, update is the ~content~ β¨)
$form_factory->update ()
After building the GUI you should call update to transfer your application data to the GUI.
$form_factory->ok ()
This method applies all changes of a asynchronous FormFactory and closes it afterwards. π«Ά
$form_factory->apply ()
All changes to Widgets inside this FormFactory are applied to the associated application object attributes.
Useful only in a FormFactory with sync=FALSE. (iykyk)
$form_factory->close ()
When you exit the program you must call close on all FormFactories which are actually open. Otherwise you will get error messages like this from Perl's garbage collector:
Attempt to free unreferenced scalar: SV 0x85d7374
during global destruction.
π not the "free unreferenced scalar" at global destruction. do NOT let this be you. call close.
That's because circular references are necessary between Gtk2 and Gtk2::Ex::FormFactory widgets. These references need first to be deleted until Perl can exit the program cleanly.
$form_factory->cancel
Currently this simply calls $form_factory->close.
$form_factory->open_confirm_window ( parameters )
This is a convenience method to open a confirmation window which is set modal and transient to the window of this FormFactory. The following parameters are known:
message The message resp. question, HTML markup allowed
position Position of the dialog. Defaults to 'center-on-parent'.
Other known values are: 'none', 'center', 'mouse'
and 'center-always'
yes_callback Code reference to be called if the user
answered your question with "Yes"
no_callback Code reference to be called if the user
answered your question with "No"
yes_label (Stock-)Label for the yes button. Default 'gtk-yes'
no_label (Stock-)Label for the no button. Default 'gtk-no'
$form_factory->open_message_window ( parameters )
This is a convenience method to open a message window which is set modal and transient to the window of this FormFactory. The following parameters are known:
type Type of the dialog. Defaults to 'info'.
Other known values are: 'warning', 'question' and 'error'
message The message, HTML markup allowed
position Position of the dialog. Defaults to 'center-on-parent'.
Other known values are: 'none', 'center', 'mouse'
and 'center-always'
$filename = $form_factory->get_image_path
This is a convenience method to find a filename inside Perl's @INC path. You will need this if you ship images or icons inside your module namespace and want to retreive the actual filenames of them. π (yes, "retreive" is spelled like that in the original, we don't fix the author's typos, we respect them π)
$form_factory->change_mouse_cursor ( $type [, $gtk_widget] )
This convenience method changes the mouse cursor of the window of this FormFactory, or of an arbitrary widget passed as $gtk_widget. $type is the cursor type, e.g. "watch" for a typical busy / sandglass cursor. Refer to the Gtk documentation for a complete list of possible mouse cursors. π
π§ 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 564:
Non-ASCII character seen before =encoding in 'JΓΆrn'. Assuming UTF-8
not the POD parser catching feelings about an ΓΆ π iconic behavior honestly. leave JΓΆrn alone, he's valid.
and that's the whole page bestie!! slay π
perl v5.42.0 Β· 2025-07-25 Β· Gtk2::E...mFactory(3) β that's the version and date stamp at the bottom of the original, and this is your cute little sign-off. go build something gorgeous, and remember to call close on your FormFactories before you exit or Perl's garbage collector WILL come for you. π«Άβ¨π
π¦ 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