mainloopが動き始めるとそのスレッドではinputなどのcui操作は使えません。やってしまうと最早event-dispatch-loopが正常に動かないのでGUIが破綻します。そこでそういうことをあえてするなら別のスレッドで行うしかないと思います。
Python
1import tkinter as tk
2import threading
3import time
4
5def run_root():
6 global root
7 root = tk.Tk()
8 f = tk.Frame(root)
9 f.pack()
10 b = tk.Button(f, text='Open', command=newWin)
11 b.pack()
12 root.mainloop()
13
14class OtherThread(threading.Thread):
15 def __init__(self):
16 super().__init__()
17
18 def run(self):
19 while True:
20 cmd = input('enter open or exit: ')
21 if cmd == 'open':
22 newWin()
23 elif cmd == 'exit':
24 root.after(0, self.stop_root)
25 break
26 print('other thread ends')
27
28 def stop_root(self):
29 root.destroy()
30 root.quit()
31
32def newWin():
33 win = tk.Toplevel(root)
34
35th = OtherThread()
36th.start()
37run_root()
38print('mainloop ends')
39th.join()
40print('end of execution')
単にwindowを開くだけなら簡単ですが、上記のように別のスレッドからウィンドウを閉じてmainloopを終了させようなんてやろうとするとmainloopが別のスレッドで実行されていることを意識したようなことをしなければならなくなります。
個人的にはGUIは単一のスレッドからのみ制御する考え方の方がプログラミングがしやすい(=素直な設計)と思います。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。