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 120867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:52:46+00:00 2026-05-11T03:52:46+00:00

My little brother is just getting into programming, and for his Science Fair project,

  • 0

My little brother is just getting into programming, and for his Science Fair project, he’s doing a simulation of a flock of birds in the sky. He’s gotten most of his code written, and it works nicely, but the birds need to move every moment.

Tkinter, however, hogs the time for its own event loop, and so his code won’t run. Doing root.mainloop() runs, runs, and keeps running, and the only thing it runs is the event handlers.

Is there a way to have his code run alongside the mainloop (without multithreading, it’s confusing and this should be kept simple), and if so, what is it?

Right now, he came up with an ugly hack, tying his move() function to <b1-motion>, so that as long as he holds the button down and wiggles the mouse, it works. But there’s got to be a better way.

  • 1 1 Answer
  • 1 View
  • 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. 2026-05-11T03:52:46+00:00Added an answer on May 11, 2026 at 3:52 am

    Use the after method on the Tk object:

    from tkinter import *  root = Tk()  def task():     print('hello')     root.after(2000, task)  # reschedule event in 2 seconds  root.after(2000, task) root.mainloop() 

    Here’s the declaration and documentation for the after method:

    def after(self, ms, func=None, *args):     '''Call function once after given time.      MS specifies the time in milliseconds. FUNC gives the     function which shall be called. Additional parameters     are given as parameters to the function call.  Return     identifier to cancel scheduling with after_cancel.''' 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been doing a little recreational holiday computing. My mini-project was a simulation
My 15 year old little brother is starting out programming, and he wrote a
I'm writing a little web-based utility for my brother who needs to merge columns
My little test-program is writing a serialized object into a mysql database, then retrieving
A little while ago I managed to get Visual Studio 2008 (C++) into a
I didn't use LINQ to SQL in project, I just went through a hand-on
This might be a little bit of a stretch, but let's just assume that
I am just getting started with JNDI for the first time. I am developing
My little brother would like to start making websites, and I've suggested Frontpage or
My little site should be pooling list of items from a table using the

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.