File: dataWalker.pl

package info (click to toggle)
libwx-perl-datawalker-perl 0.02-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 96 kB
  • sloc: perl: 520; makefile: 9
file content (69 lines) | stat: -rw-r--r-- 1,191 bytes parent folder | download | duplicates (3)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env perl
use strict;
use warnings;
use Wx;
use Wx::Perl::DataWalker;
use YAML::XS;
use Getopt::Long qw(GetOptions);

sub usage {
  my $msg = shift;
  warn("$msg\n\n") if defined $msg;

  warn <<HERE;
Usage: $0 --eval '{foo => "bar", baz => []}'
       $0 --yaml YAMLFILE
HERE
  exit(1);
}

my $eval;
my $yamlfile;
GetOptions(
  'h|help' => \&usage,
  'e|eval=s' => \$eval,
  'y|yaml=s' => \$yamlfile,
);

if (1!=grep {defined $_} ($eval, $yamlfile)) {
  usage("You need to supply exactly one of the --eval or --yaml options");
}

my $data;
if (defined $eval) {
  $data = eval "$eval";
  if ($@) {
    usage("Could not eval your expression: $@");
  }
}
elsif (defined $yamlfile) {
  usage("Could not find YAML input file '$yamlfile'") unless -f $yamlfile;
  $data = YAML::XS::LoadFile($yamlfile)
}
else {
  die "Should not happen";
}

package MyApp;
our @ISA = qw(Wx::App);

sub OnInit {
    my $self = shift;

    my $frame = Wx::Perl::DataWalker->new(
      {data => $data},
      undef, -1,
      "dataWalker",
    );
    $self->SetTopWindow($frame);
    $frame->Show(1);
    $frame->SetSize(500,500);

    return 1;
}


package main;
my $app = MyApp->new();
$app->MainLoop();