Here is an example script demonstrating Config::Model. It displays the
gui and provides a configuration value, the user can modify. It should
be added in the examples section of the Config::Model::TkUI manpage.
ATM, there is no sub for writing the config.
Note that there are warnings when pushing around with the buttons in
the edit dialog: Use of uninitialized value in scalar chomp at C:/Perl/
site/lib/Config/Model/Tk/LeafEditor.pm line 181.
Use of uninitialized value in concatenation (.) or string at C:/Perl/
site/lib/Config/Model/Tk/LeafEditor.pm line 183.
HTH, Alex
Subject: | model.pl |
#!/Perl/bin/perl
use strict;
use warnings;
use Config::Model;
use Config::Model::TkUI;
use Log::Log4perl qw(:easy);
use FindBin qw/$Bin/;
# -- init trace
Log::Log4perl->easy_init($WARN);
# -- create configuration instance
my $model = Config::Model->new();
# -- create config model
$model->create_config_class(
name => "SomeRootClass",
element => [
country => {
type => 'leaf',
value_type => 'enum',
choice => [qw/France US/]
},
],
);
my $inst = $model->instance(
root_dir => $Bin,
root_class_name => 'SomeRootClass',
instance_name => 'test'
);
my $root = $inst->config_root();
# -- Tk part
my $mw = MainWindow->new();
$mw->withdraw();
$mw->ConfigModelUI(-root => $root);
$mw->MainLoop();