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

  • Home
  • SEARCH
  • 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 9023403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:45:12+00:00 2026-06-16T05:45:12+00:00

So there I was just messing around in an interpreter when I came across

  • 0

So there I was just messing around in an interpreter when I came across a strange problem. I was just trying to make a bouncing smiley face to brighten my day, but for some reason I’m unable to do this. And I have no desire to do this in Pygame, if anyone thinks to suggest that. This isn’t a project, it was just something silly I was doing and don’t understand why it’s not working.

from Tkinter import *
import time,random

root = Tk()
root.geometry("500x500")
root.mainloop()
bouncer = Label(root, text="=D")

def bounce ():
    X = random.randint(1,500)
    Y = random.randint(1,500)
    bouncer.place(x=X, y=Y)

while True:
    time.sleep(0.5)
    bounce()

This code does not work, and I for the life of me can’t figure out why. What ends up happening is the loop runs forever, and when I ^C bounce() gets called once and the script ends. I tried it in a for loop to see if I could just bounce 100 times, but bounce() would just call once after the loop finished. I’m fairly stumped on this.

Any ideas, anyone?

  • 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-16T05:45:13+00:00Added an answer on June 16, 2026 at 5:45 am

    sleep puts the process to the sleep state. Better use after.

    from Tkinter import *
    import time,random
    
    root = Tk()
    root.geometry("500x500")
    bouncer = Label(root, text="=D")
    
    def bounce ():
        X = random.randint(1,500)
        Y = random.randint(1,500)
        bouncer.place(x=X, y=Y)
        root.after(1000, bounce)
    
    bounce()
    root.mainloop()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just messing around with some C++ at the moment trying to make a
Is there any way (just out of curiosity because I came across multiple same-value
I'm just messing around trying to learn a little bit about parallel computing. If
Just messing around with Rails 3.1, which separates stylesheets via controllers. I'm assuming there
I'm trying to create a shell (nothing serious just messing around) and want to
I'm new to Cocoa Touch and I'm just messing around trying to get a
Hey guys, I'm working on a status-Updater. It works, there is just one problem,
I was just messing around with the new HTML5 tags and pseudo selectors and
I've just been messing around with threads in Java to get my head around
I've been messing around with IDA Pro and trying to disassemble my own products

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.