I have difficulties with tkinter and it turns out that I have created a root window, which inherits UI.
from tkinter import *
from ttkthemes import themed_tk as tk
from tkinter import ttk
import tkinter.messagebox as tmb
class UI(Frame):
def __init__(self,parent=None):
Frame.__init__(self,parent)
self.parent = parent
self.parent = tk.ThemedTk()
self.parent.set_theme("arc")
self.parent.geometry("480x520")
self.init_ui()
def init_ui(self):
self.parent.title("Nueva ventana heredada")
ventana = ttk.Frame(self.parent)
ventana.pack()
entrada = ttk.Entry(ventana,text="ingresa")
entrada.grid(row=2,column=2)
#---------------------------------------------------
def ver():
try:
res = int(entrada.get())
print(res)
except ValueError:
tmb.showwarning(title="error",message=" error")
#-------------------------------------------------
boton = ttk.Button(ventana,text="pulsame", command=ver)
boton.grid(row=2, column=3)
if __name__== '__main__':
root = Tk()
sug = Label(root, text="aqui es para escribir")
sug.pack()
app = UI(parent=root)
app.mainloop()
root.destroy()
As you can see, when I press the button, a number should appear on the console, of course if you wrote it, otherwise two windows will appear and one of those is
tmb.showwarning(title="error",message=" error")
the other one is the root window, I want there to be no other window and I suspect the topic that I have given it.
self.parent = tk.ThemedTk()
self.parent.set_theme("arc")
Could you help me please?