2

I am able to embed a xterm into a Tkinter GUI Frame:

Frame2 = Frame(master)
Frame2.pack(fill=BOTH, expand=YES)
wid = Frame2.winfo_id()
os.system('xterm -into %d -hold -geometry 300x10 -sb &' % wid)

But this doesn't work:

Frame2 = Frame(master)
Frame2.pack(fill=BOTH, expand=YES)
wid = Frame2.winfo_id()
os.system('gnome-terminal' % wid)

TypeError: not all arguments converted during string formatting

Can I embed a konsole or gnome-terminal at the frame in any way?

  • In `'gnome-terminal' % wid` there is no place for the `wid` value to be put in the string. You should probably have a `%d` in there somewhere. – fhdrsdg May 29 '18 at 10:33
  • If I do os.system('gnome-terminal -into %d -hold -geometry 300x10 -sb &' % wid) it syas unknown option -into (also --into). –  May 29 '18 at 11:38
  • This is not the solution. I don't find an equivalent to -into on xterm sentence. But well, what I did is to change the background, and now looks more like konsole, wich is the one I would like to insert on the frame. os.system('xterm -fg white -bg black -into %d -hold -geometry 300x10 -sb &' % wid) –  May 29 '18 at 11:55
  • I'm not saying I have a solution to your problem (because honestly I don't even understand what you want), I just told you where the TypeError you got came from. – fhdrsdg May 29 '18 at 12:28
  • Yes I tried several things. You are rigth with not %d it don't concatenates with the frame id, but problem is -into (neither --into) is recognized when you are not embedbing xterm but konsole or gnome-terminal. I am able to open both but only with xterm inside the frame. I find the way to open a gnome-terminal or konsole, but not inside the tkinter frame. Anyhow thank you for your answer. It clarifies a bit why I am not able. Any link to properties on os.system for gnome-terminal or konsole? I don't find anything at all related with this. –  May 29 '18 at 12:37
  • I have done xterm -help and that -into option is shown, but I don't see any equivalent to into for gnome-terminal or konsole with the help command –  May 29 '18 at 13:13
  • @fhdrsdg: Excuse my bad english. I was trying to say to use -into at a xterm was not the solution. Your %d appoint was useful because then the message "-into is not recognized as an option" appeared, I could find the options at help menu sugested, and finaly find I can edit style. I wonder if it is possible realy to embebd konsole or gt on python tkinter. –  May 29 '18 at 14:37

2 Answers2

2

Also urxvt and st (Suckless Simmple Terminal) have an option to embed the terminal window into another one.

I do this in Gtk, but keep in mind that with Wayland they are all removing the support to socket and plugs, that is this mechanism of embedding windows in other ones.

tmow
  • 195
  • 1
  • 13
0

I have not a lot of experience on Ubuntu, but after typing

  • xterm -help
  • konsole -help
  • gnome-terminal --help

I realized maybe xterm is the best terminal to embed on a tkinter frame, as I didn't know I could edit

/etc/X11/Xresources/x11-common (I am running kubuntu 18.04)

and change as much as I want the style of the terminal:

XTerm*faceName: Bitstream Vera Serif Mono
xterm*faceSize: 11
xterm*vt100*geometry: 80x60
xterm*saveLines: 16384
xterm*loginShell: true
xterm*charClass: 33:48,35:48,37:48,43:48,45-47:48,64:48,95:48,126:48
xterm*termName: xterm-color
xterm*eightBitInput: false

!BLK Cursor
#define _color0        #000d18
#define _color8        #000d18
!RED Tag
#define _color1        #e89393
#define _color9        #e89393
!GRN SpecialKey
#define _color2        #9ece13
#define _color10       #9ece13
!YEL Keyword
#define _color3        #f0dfaf
#define _color11       #f0dfaf
!BLU Number
#define _color4        #8cd0d3
#define _color12       #8cd0d3
!MAG Precondit
#define _color5        #c0bed1
#define _color13       #c0bed1
!CYN Float
#define _color6        #dfaf8f
#define _color14       #dfaf8f
!WHT Search
#define _color7        #efefef
#define _color15       #efefef
!FMT Include, StatusLine, ErrorMsg
#define _colorBD       #ffcfaf
#define _colorUL       #ccdc90
#define _colorIT       #80d4aa
!TXT Normal, Normal, Cursor
#define _foreground    #dcdccc
#define _background    #1f1f1f
#define _cursorColor   #8faf9f
URxvt*color0         : _color0
URxvt*color1         : _color1
URxvt*color2         : _color2
URxvt*color3         : _color3
URxvt*color4         : _color4
URxvt*color5         : _color5
URxvt*color6         : _color6
URxvt*color7         : _color7
URxvt*color8         : _color8
URxvt*color9         : _color9
URxvt*color10        : _color10
URxvt*color11        : _color11
URxvt*color12        : _color12
URxvt*color13        : _color13
URxvt*color14        : _color14
URxvt*color15        : _color15
URxvt*colorBD        : _colorBD
URxvt*colorIT        : _colorIT
URxvt*colorUL        : _colorUL
URxvt*foreground     : _foreground
URxvt*background     : _background
URxvt*cursorColor    : _cursorColor
XTerm*color0         : _color0
XTerm*color1         : _color1
XTerm*color2         : _color2
XTerm*color3         : _color3
XTerm*color4         : _color4
XTerm*color5         : _color5
XTerm*color6         : _color6
XTerm*color7         : _color7
XTerm*color8         : _color8
XTerm*color9         : _color9
XTerm*color10        : _color10
XTerm*color11        : _color11
XTerm*color12        : _color12
XTerm*color13        : _color13
XTerm*color14        : _color14
XTerm*color15        : _color15
XTerm*colorBD        : _colorBD
XTerm*colorIT        : _colorIT
XTerm*colorUL        : _colorUL
XTerm*foreground     : _foreground
XTerm*background     : _background
XTerm*cursorColor    : _cursorColor
  • The problem I see is every time I reboot my system I need to exeute xrdb -merge /etc/X11/Xresources/x11-common. I will need to execute a proccess with that command everytime my programm launches I think –  May 29 '18 at 14:52