1

I am making a simple Python program which I want to run gnome terminal into it. I've done some research and I have found this answer, but I want to embed gnome terminal not xterm. The linked question's answer uses xterm -into but gnome-terminal does not seem to have a comparable option.

Sylvester Kruin
  • 3,294
  • 5
  • 16
  • 39
Prt23
  • 11
  • 1
  • 2
    Unless you are *specifically* asking about how to solve a cross-version compatibility problem (in which case your question should obviously describe that problem) you should not mix the [tag:python-2.7] and [tag:python-3.x] tags. This also doesn't appear to have anything with [tag:bash] to do. I have removed these spurious tags. – tripleee Nov 03 '21 at 17:41
  • Alright thanks – Prt23 Nov 03 '21 at 17:43
  • Anyway, the obvious solution is to replace the `xterm` call in the other question with a `gnome-terminal` command line. The available options obviously differ but that's the gist of it (though using `subprocess` instead of `system` would be an improvement). – tripleee Nov 03 '21 at 17:44
  • I did it but apparently there is no option for gnome terminal to embed it to other applications. – Prt23 Nov 03 '21 at 17:46
  • https://stackoverflow.com/questions/50581791/embed-a-konsole-or-gnome-terminal-inside-a-tkinter-frame appears to ask the same question, but it doesn't have a (proper) answer. – tripleee Nov 03 '21 at 17:52
  • Running `gnome-terminal --help-all` shows a list of all the options. Judging by what's there, there isn't any simple way to embed `gnome-terminal` in a `tkinter` window. However, maybe you run the terminal (I mean like `bash`, `sh`, etc.) in a process, and change it's stdin and stdout so that they go to your program... – Sylvester Kruin Nov 03 '21 at 21:39

1 Answers1

1

gnome-terminal is a GTK app, Tkinter creates TCL app: both libraries will interact with the underlying window manager in very different ways and likely with some conflict (in handling/consuming input events, for example).

Since the embed option does not exist, to start with, I´d say this is not feasible but for setting a raw framebuffer inside the tkinter app, and somehow routing the gnome-terminal to use an emulated/contained window manager in that framebuffer - that would be at least an order of magnitude more complex than any answer you might be looking for.

Instead, if you want to give the user of your app a raw shell in a terminal app, and can't live with simply popping it up in another window, is to re-do your application using GTK instead of tkinter, and check in the gnome-terminal development docs/source code if the main terminal widget can be used stand-alone in another app.

jsbueno
  • 99,910
  • 10
  • 151
  • 209
  • And for information on how to embed a terminal in a Gtk window, see [this question](https://stackoverflow.com/q/60454326/16775594). – Sylvester Kruin Nov 04 '21 at 14:58