G
G
Grandma Luda2021-06-10 19:08:03
Python
Grandma Luda, 2021-06-10 19:08:03

Why are widgets not added to child window?

from tkinter import*
from clientcore import*
from tkinter import scrolledtext as scr

class ChildWindoDownlots():
    def childwindowdownlots(self):
        self.childwind = Toplevel(self.root)

        self.chk_state = BooleanVar()  
        self.chk_state.set(True) 
        self.checkbox = Checkbutton(self.childwind, text='Выбрать', var=self.chk_state)
        self.grid(column=0, row=0)

        self.btn = Button(self.childwind, text="gg")
        self.btn.grid(column=1, row=0)
        
        self.childwind.grab_set()

class ChildWindowInstall():
    def childwindowinstall(self):
        self.childwind = Toplevel(self.root)
        self.childwind.grab_set()

class Window(ChildWindowInstall, ChildWindoDownlots):
    def __init__(self):
        self.root = Tk()
        self.root.title("client")
        self.root.geometry("400x300")
        self.root.resizable(width=False, height=False)
        self.root.iconbitmap(r"images/client.ico")
        self.root["bg"] = "gray22"

        self.btn_install = Button(self.root, text="Install", command=self.childwindowinstall).place(x=10, y=10, width=190, height=50)
        self.btn_downlots = Button(self.root, text="Downlots", command=self.childwindowdownlots).place(x=200, y=10,width=190, height=50)
        self.console = scr.ScrolledText(self.root, state=DISABLED)
        self.console.place(x=10, y=70, width=380, height=220)

        self.insert_console('text')
        
        self.root.mainloop()

    def insert_console(self, content):
        self.console.configure(state=NORMAL)
        self.console.insert(INSERT, content)
        self.console.configure(state=DISABLED)
        

if __name__ == "__main__":
    Window()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vadim Simakin, 2021-06-11
@Vadessa

Tkinter is designed to be single window only. Two windows are better not to do.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question