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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:47:49+00:00 2026-06-15T03:47:49+00:00

from tkinter import * class GameBoard(Frame): def __init__(self): Frame.__init__(self) self.master.title(test) self.grid() #button frame self.__buttonPane

  • 0
from tkinter import *

class GameBoard(Frame):
  def __init__(self):
    Frame.__init__(self)
    self.master.title("test")
    self.grid()
    #button frame
    self.__buttonPane = Frame(self)
    self.__buttonPane.grid()
    #buttons
    self.__buttonA1 = Button(self.__buttonPane,text = "A1",command = self._close)
    self.__buttonA1.grid()

  def _close(self):
    GameBoard().destroy()


def main():
  GameBoard().mainloop()

main()

How would I make my function for close to work?

  • 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-15T03:47:51+00:00Added an answer on June 15, 2026 at 3:47 am
    GameBoard()
    

    creates a new instance of GameBoard. Therefore:

    GameBoard().destroy()
    

    creates a new instance and calls destroy() on it which has no effect on the existing instance.

    You want access the current instance in your _close() method which is done through self:

    def _close(self):
        self.destroy()
    

    However, this only destroys the frame (and its child windows, like the button), not the top level window (master).

    To completely close the UI, you could call self.master.destroy() or simply self.quit():

    def _close(self):
        self.quit()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

from TKinter import * class Ui(Frame): def __init__(self) Frame.__init__(self, None) self.grid() bquit=Button(self, text=Quit, command=self.quit_pressed)
from Tkinter import * class Output: def __init__(self,master): self.u=Text(master,width=40) self.u.grid(row=0,column=0) self.v=Button(master,text=Add text,command=Write) self.v.grid(row=1,column=0) def
from Tkinter import * class StatusBar(Frame): def __init__(self, master): Frame.__init__(self, master) self.label = Label(self,
here is some code: from Tkinter import * class Main(object): def __init__(self): self.console =
I have the following code: from tkinter import * class MyApplication(Tk): def __init__(self): super().__init__()
Something like this: from Tkinter import * root = Tk() but = Button(root, text
I've created this simple GUI: from tkinter import * root = Tk() def grabText(event):
How does adding master = Tk() into the __init__ of a subclass of tkinter.Frame
so when i run this code and click the button: from Tkinter import *
Here is my code: from tkinter import * from tkinter.ttk import * class App:

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.