Getting tkinter dialog to notify the user that their input is invalid Getting tkinter dialog to notify the user that their input is invalid tkinter tkinter

Getting tkinter dialog to notify the user that their input is invalid


If you are looking to simply tell the user the input was invalid you can do

from tkinter import messageboxmessagebox.showinfo("Title", "Input invalid.")

Messagebox does need to be imported separately from tkinters main library.

That being said you need to import tkinter only once. You are currently importing tkinter 3 times with:

import tkinterfrom tkinter import *import tkinter as tk

instead you should use:

import tkinter as tk

you can use this for most of tkinter methods. You just need to use the prefix tk. on your widgets.

examples tk.Entry(), tk.Label(), tk.Text() and so on.

As for your extra blank windows that are opening they are coming from your __init__ portion of your class.

class TimeConverterUI():    def __init__(self):        self.quitValue=tk.Toplevel() # causing an empty toplevel window to open in init        self.invalidinputDialog=tk.Toplevel() # causing an empty toplevel window to open in init

You do not need to set up the toplevel ahead of time. You can simply create it in a method when you need one.