Tk-Taxis

 view release on metacpan or  search on metacpan

eg/woodlice.pl  view on Meta::CPAN


my %mode = 
(
	none                    =>
	{
		fill =>
		[
			[ '#7DDE4D', '#7DDE4D' ],
			[ '#7DDE4D', '#7DDE4D' ],
		],
		prefs => [ 1, 1 ],
	},	
	dry                     => 
	{
		fill =>
		[
			[ '#C1B24E', '#C1B24E' ],
			[ '#7695EF', '#7695EF' ],
		],
		prefs => [ 1, 7 ],
	},
	light                   => 
	{
		fill =>
		[
			[ 'white', 'gray' ],
			[ 'white', 'gray' ],
		],
		prefs => [ 1000, 1 ],
	},
	both                    =>
	{
		fill =>
		[
			[ '#F6D388', '#705824' ],
			[ '#B7C8DB', '#215187' ],
		],		
		prefs => [ 1000, 7 ],
	}
);

################################# defaults #####################################

my $population   = 20;
my $critters     = 'woodlice';
my $vert         = 500;
my $horiz        = 500;
my $speed        = 0.006;

eg/woodlice.pl  view on Meta::CPAN

		(
			-column    => 1,
			-row       => 0,
			-rowspan   => 2,
			%pad_opt,
		);
			my $taxis = $taxis_frame->Taxis
			( 
				-width      => $horiz,
				-height     => $vert,
				-preference => $mode{$mode}{prefs},
				-fill       => $mode{$mode}{fill},
				-population => $population,
				-images     => $critters,
				-speed      => $speed,
			)
			->pack();
		
		$counters{ top_right } = $main->Label
		( 
			%label_opt,

eg/woodlice.pl  view on Meta::CPAN

		-text         => "OK", 
		-font         => "sserif 14",
		-command      => [
						sub
						{
							$population = $population_scale->get();
							$taxis->configure( -population => $population ); 
							if ( $light && $dry )
							{
								$taxis->configure( -fill => $mode{both}{fill} );
								$taxis->configure( -preference => $mode{both}{prefs} );
							}
							elsif ( $dry )
							{
								$taxis->configure( -fill => $mode{dry}{fill} );
								$taxis->configure( -preference => $mode{dry}{prefs} );
							}
							elsif ( $light )
							{
								$taxis->configure( -fill => $mode{light}{fill} );
								$taxis->configure( -preference => $mode{light}{prefs} );
							}
							else
							{
								$taxis->configure( -fill => $mode{none}{fill} );
								$taxis->configure( -preference => $mode{none}{prefs} );
							}							
							$option_box->destroy();
							$taxis->refresh();
							$supress_refresh = 1;
						}
					],
		-width        => 10,
	)->grid
	(
		-column       => 1,



( run in 2.748 seconds using v1.01-cache-2.11-cpan-8f98c5d2c55 )