Hack Forums
[Python] Open New Console Window - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] Open New Console Window (/showthread.php?tid=5509103)



Open New Console Window - Solar_Flare - Dec 30, 2016

Okay, in Python 3,

How can I open a new console window within the original console? For example, I have a series of instructions within my first window etc, but I would like to open a new console that handles a new set of instructions.

--Goal is to open a new console window once I hit enter. [img][IMG]http://i95.photobucket.com/albums/l146/TheSnyderizer/Decoder_zpslpj91ujb.jpg[/IMG][/img]

Any ideas?

Thanks in advance


* - Goodies - Dec 30, 2016

There's no cross platform way to do this. In fact, on some systems, there may be no reliable way to do this at all.

Terminal emulators on Linux (xterm, rxvt, gnome-terminal, konsole, etc...) are too numerous.

This is a good SO resource on the topic. You're not going to get native python to do this universally. To be reliable, you'd need to use PyQt or similar cross-platform GUI resource and probably create a emulator or at least a little GUI to show what you want it to show.

http://stackoverflow.com/questions/19308415/execute-terminal-command-from-python-in-new-terminal-window


* - Solar_Flare - Dec 30, 2016

Okay, If this is the case than. How can I clear the current console which emulates the idea of starting a new console.

For example, After I hit enter, how can I emulate a script that wipes the console clean??

same idea as a Linux terminal script like:

user@Terminal:~$ "Clear"

Thanks


* - Goodies - Dec 30, 2016

Once again, there is no universal way.

Among the safest would be cls/clear for windows/unix respectively, but there's simply no guarantee.
PHP Code

<?php 
import os
import subprocess

def clear
():
    
subprocess.Popen("cls" if os.name == "nt" else "clear", shell=True) 



* - Solar_Flare - Dec 30, 2016

(Dec 30, 2016 04:11 PM)Goodies Wrote:  Once again, there is no universal way.

Among the safest would be cls/clear for windows/unix respectively, but there's simply no guarantee.
PHP Code

<?php 
import os
import subprocess

def clear
():
    
subprocess.Popen("cls" if os.name == "nt" else "clear", shell=True) 

Okay shoot! Thanks for reaching out! Cheers..