Last active
March 30, 2023 18:34
-
-
Save zed/7389278 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| """Show messages in two new console windows simultaneously. | |
| See http://stackoverflow.com/q/19479504 | |
| """ | |
| import sys | |
| import platform | |
| from subprocess import Popen | |
| messages = 'This is Console1', 'This is Console2' | |
| # define a command that starts new terminal | |
| if platform.system() == "Windows": | |
| new_window_command = "cmd.exe /c start cmd.exe /c".split() | |
| else: #XXX this can be made more portable | |
| new_window_command = "x-terminal-emulator -e".split() | |
| # open new consoles, display messages | |
| echo = [sys.executable, "-c", | |
| "import sys; print(sys.argv[1]); input('Press Enter..')"] | |
| processes = [Popen(new_window_command + echo + [msg]) for msg in messages] | |
| # wait for the windows to be closed | |
| for proc in processes: | |
| proc.wait() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment