在另一个窗口中打包小部件的问题

问题描述 投票:0回答:0

我有一个问题,我需要在新窗口中单击按钮从 tkterminal 库中打包终端并销毁它(如切换),但是终端正在打包到已经存在的“根”窗口中,所以有一个代码:

def open_terminal():
    global debounce
    if debounce == True:
        global cmd
        cmd = tk.Toplevel(root)
        cmd.title("Terminal")
        global terminal
        terminal = Terminal(pady=5, padx=5)
        terminal.basename = "dolphinwriter$"
        terminal.shell = True
        terminal.pack(cmd, side="top", fill="both", expand=True)
        debounce = False
        print(debounce)
    else:
        cmd.destroy()
        debounce = True

我正在尝试这个:

  1. 检查是否已经终端打包到根窗口,如果是,解压并再次打包
  2. 打包终端,不检查再打包。 我尝试使用 pack_forget() 方法完成上述所有操作
python tkinter tk-toolkit pack
© www.soinside.com 2019 - 2024. All rights reserved.