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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:52:08+00:00 2026-05-21T23:52:08+00:00

So I am trying to use Tkinter to receive a text input, and then

  • 0

So I am trying to use Tkinter to receive a text input, and then run pygames from that to do an animation. I get an error though when I close Pygames.

A simplified version of how I plan to use Pygames:

def the_program():
    if spot.get().strip() == "":
        tkMessageBox.showerror("X", "Y")
    else:
        code = spot.get().strip()
        pygame.init()
        pygame.display.set_caption('X')
        windowSurface = pygame.display.set_mode((WINDOWWIDTH, WINDOWHEIGHT), 0, 32)
        while True:
            for event in pygame.event.get():
                if event.type == QUIT:
                    pygame.quit()
                    sys.exit()
            pygame.display.update()

Running Tkinter:

root = Tk()
frame = Frame(root)
text = Label(frame, text='X')
spot = Entry(frame)
button = Button(frame, text = 'Ready?', command = the_program) "Starts Pygames"
frame.pack()
text.pack()
spot.pack()
button.pack()

root.mainloop()

Pygames opens up fine and runs well, but when I close it I get this error:

Traceback (most recent call last):
  File "C:\Python26\Practice\legit Battle Master.py", line 82, in <module>
    root.mainloop()
  File "C:\Python26\lib\lib-tk\Tkinter.py", line 1017, in mainloop
    self.tk.mainloop(n)
  File "C:\Python26\lib\lib-tk\Tkinter.py", line 1412, in __call__
    raise SystemExit, msg

How can I avoid this? I tried removing “sys.exit()”, but python crashes.

  • 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-05-21T23:52:09+00:00Added an answer on May 21, 2026 at 11:52 pm

    You are trying to exit from the pygame mainloop with sys.exit(), which exits the whole running application, including the tkinter GUI you started before pygame. You should exit the pygame mainloop (the only while clause) with a conditional. e.g:

    running = True
    while running:
        for event in pygame.event.get():
            if event.type == QUIT:
                pygame.quit()
                running = False
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use an Entry field to get manual input, and then work
I'm trying use this code to get image resolution from file bool GetImageSizeEx(const char
I was trying use a set of filter functions to run the appropriate routine,
I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The
trying to use this route: from(activemq:profiles).aggregate(header(cheese)).batchSize(30).bean(ProfilesQueueService, saveContacts) Fails with: No signature of method: org.apache.camel.model.RouteType.aggregate()
I am trying to use networkx with Python. When I run this program it
I'm trying to center a tkinter window. I know I can programatically get the
I am trying use std::copy to copy from two different iterator. But during course
I'm trying to use tkinter to periodically refresh a square grid. Each square in
i'm trying use webview to load a image from sdcard i use this path

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.