Reputation: 169
I have made a programm with some simple Tkinter windows, for example a 'Hello' label. Is it possible to type and give commands in Python Shell simultaneously? I tried but Python Shell doesn't appear '>>>' to give commands,so when i type and press Enter , the cursor goes to the next line,instead of running the string. I hope you get my point
Upvotes: 1
Views: 195
Reputation: 14873
You want to see the open window and simultaniously execute commands behind >>>
.
Two solutions I see:
remove xxx.mainloop()
when you execute it with the Python Shell. I did it like this conditionally.
import sys
if 'idlelib' not in sys.modules:
xxx.mainloop()
start the mainloop in another thread. You should not do this in production code because Tkinter is not threadsafe.
import threading
t = threading.Thread(target = xxx.mainloop)
t.start()
These are two solution I could think of because 1.
may not always work.
Upvotes: 1