1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
#!/usr/bin/perl
#
# This file is part of Config-Model-TkUI
#
# This software is Copyright (c) 2008-2021 by Dominique Dumont.
#
# This is free software, licensed under:
#
# The GNU Lesser General Public License, Version 2.1, February 1999
#
# (c) 2009 Alexander Becker <asb_ehb at yahoo.de>
# (c) 2009 Dominique Dumont <ddumont at cpan.org>
# example contributed by Alexander Becker
# Adapted to Unix and streamlined by Dominique Dumont
# See https://rt.cpan.org/Ticket/Display.html?id=49999
use strict;
use warnings;
use Config::Model;
use Config::Model::TkUI;
use Log::Log4perl qw(:easy);
# -- 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_class_name => 'SomeRootClass',
);
my $root = $inst->config_root();
# -- Tk part
my $mw = MainWindow->new();
$mw->withdraw();
$mw->ConfigModelUI(-root => $root);
$mw->MainLoop();
|