user5740460
user5740460

Reputation:

How to open new bash terminal using Python

I am trying to open a new terminal window in Tkinter application. I've used os.system("/bin/bash") but it works in current bash only. Which stops runnning code and causes application freeze. I want to open new Terminal. How to do that? gedit like programs work fine without disturbing current apllication.

def openterm():
    os.system("/bin/bash")
def opengedit():
          os.system("/usr/bin/gedit")
menu = tk.Menu(root)
root.config(menu=menu)
subMenu = tk.Menu(menu)
menu.add_cascade(label="Tools", menu=subMenu)
subMenu.add_command(label="Open Terminal", command=openterm)
subMenu.add_command(label="Open Gedit", command=opengedit)      

Upvotes: 1

Views: 5382

Answers (3)

K1rma
K1rma

Reputation: 1

I found an answer to this all you have to do is

os.system(exo-open --launch TerminalEmulator")

THAT'S IT FOLKS !!!

Upvotes: 0

Jonathan
Jonathan

Reputation: 86

I don't know exactly how to explain it in code but I can point you in the right direction. Its an example from windows command prompt though. When you are in command prompt the way to open a new window is to type "start prompt" from the already open one. Maybe if you apply this same methodology to your script it will work. Hopefully I was of some help to you.

Upvotes: 0

Robᵩ
Robᵩ

Reputation: 168626

Try this:

# Tested on Ubuntu 14.04.3 LTS
os.system("x-terminal-emulator -e /bin/bash")

Upvotes: 9

Related Questions