Maybelle Galicia
Maybelle Galicia

Reputation: 1

Closing my message box and root window in python 3.6

import statements

import from tkinter import *
import tkinter.simpledialog
import tkinter.messagebox
from tkinter import ttk
from time import strftime
now = strftime( "%x %Z %X")

Setting window

root=Tk()
root.title("ON TOP OF THE WORLD")
canvas= Canvas(root, width=350, height=250)
canvas.pack()
photo=PhotoImage(file='/Users/m/Desktop/TOTW.gif')
canvas.create_image(0, 0, anchor = NW, image=photo)

Welcome User

tkinter.messagebox.showinfo("Hello,today is", now)

ask user

name=tkinter.simpledialog.askstring("name","What is your name?" )

input process

output = "Hello, %s! May the only place you find yourself today is on top of the world !" %name

show output

tkinter.messagebox.showinfo(now, output)

CLOSE

def on_closing():
    if tkinter.messagebox.askokcancel("Quit", "Do you want to quit?"):
        root.destroy()

root.protocol(on_closing)
root.mainloop()

I need help in closing or ending this dialogue box

Upvotes: 0

Views: 4803

Answers (1)

HalfIrish
HalfIrish

Reputation: 61

You could take two other approaches to this, one being quit() and simply ending the code all together, or using frames in tkinter and calling a different frame whether it says close or comes up blank. It would be able to cover everything already there

Upvotes: 1

Related Questions