Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9007107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:35:51+00:00 2026-06-16T01:35:51+00:00

I wrote cellular automaton (Conway’s Game of Life) using Perl and TK, just for

  • 0

I wrote cellular automaton (Conway’s Game of Life) using Perl and TK, just for fun and practice. It works fine with console output. When I use TK, in first version I just delete and add new cells (rectangles), and after about 100 steps my program has slowed down (about 10 times). Then I rewrote graphics part: initially made all of 2500 cells (50×50) and then changing their color instead of adding/deleting them. But after 600-700 steps my reworked automaton begins to slow down too.

This is a feature/bug of TK or I do something wrong?

Changing color by tag:

$canvas->itemconfigure("cell"."$x $y", -fill=>'blue');

Creating grid:

for($y = 0; $y < 50; $y++)
{
    for($x = 0; $x < 50; $x++)
    {
        $canvas->createRectangle($x * 10, $y * 10, ($x + 1) * 10, ($y  + 1) * 10, -fill=>'white', -tags=>["cell"."$x $y"]);
    }
}

Start and stop loop:

sub start
{
    $repeat = $MainWindow->repeat($speed, sub{&maketurn;});
    # Function "maketurn" is not important, it is a simple counting of "alive" cells
    # and changing color by tag
}

sub stop
{
    if(defined($repeat))
    {
        $repeat->cancel();
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T01:35:53+00:00Added an answer on June 16, 2026 at 1:35 am

    I found an articles about the tk canvas widget being slow with many items. The problem sounds very similar to your problem:

    http://code.activestate.com/lists/perl-tk/17282/

    The solution may be to use the tk photo widget which behaves much like a bitmap. This would be a little of a pain to adapt your code to but it seems like the canvas widget is inherently slow with many objects.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a VB.NET Windows Service, which works fine. I have only one issue
I wrote a game in c++ using SDL. The game currently updates a highscore
I wrote a process explorer using C with GUI interface. I want to add
I wrote an application using the Android 2.2 SDK (API level 8). It is
I wrote a piped shell command that has multiple pipes in it that works
I wrote a file parser for a game I'm writing to make it easy
I wrote some test code that compares the speed of using the append() method
I wrote a macro that imports a CSV file into my spreadsheet, using a
I wrote a console program in c# that takes up to three files as
I wrote a very simple perl script, and now I want to make it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.