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 trying to use ImageInfo and Jython to get information from a image on
Trying to use make from cygwin using g++ I was getting Access Denied error
I'm trying to use SQLBindParameter to prepare my driver for input via SQLPutData .
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 revieving the following error when trying use mysql_real_escape() function Fatal error: Call to
I'm trying to use tkinter to periodically refresh a square grid. Each square in
I am trying use the django ORM to get a list by year of
Trying to use a lib but getting this error... npm ERR! JSON.parse Failed to
Trying to use Excel VBA to capture all the file attributes from files on

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.