[Tkinter-discuss] embedding in Tkinter
Alessandro Magni
alexxx.magni at gmail.com
Tue Sep 6 14:24:35 CEST 2011
Hi everybody,
I hope somebody here can give me a hand - I'm not so expert in GUI programming.
I tried - in a Tkinter program I'm writing - to embed a terminal
(linux here) in the main window - the program is a simple wiki, and I
believe it's useful to have a small terminal handy...
Optionally, I would like also to be able to let my program interact
with the terminal - at a minimum I'd like to read the current working
directory, and to set it.
I tried asking about it on stackoverflow, but without much results
(apart from some suggestions about pyGTK being the wave of the future,
of course...)
I don't know if it is really impossible - but at least I was able to
do it in the past with Perl/Tk, so maybe it can be replicated here.
The code I used then was something like:
$frame3=$mw->Frame();
$cv=$frame3->Canvas()->pack(-expand => 1, -fill => 'both');
my $xtermContainer = $cv->Frame(-container => 1); # this Frame is
needed for including the xterm in Tk::Canvas
my $xtid = $xtermContainer->id();
my ($xtId) = sprintf hex $xtid; # converting the id from HEX to
decimal as xterm requires a decimal Id
my $dcontitem = $cv->createWindow($xtermWidth/2,$xtermHeight/2,
-window => $xtermContainer,
-width => $xtermWidth,
-height => $xtermHeight,
-state => 'normal');
system("xterm -into $xtId -fn $fontname -geometry $geometry +sb -bg
black -fg white -e ./xtermjob.pl &");
(...hoping no python purist wants to shoot me in the head for showing
perl in a python mailing list :-)
I tried using a code similar to the following, but it doesnt work...
termf = Frame(root)
termf.pack(side=BOTTOM, fill=X)
id=termf.winfo_id()
os.system("xterm -into %d -e /root/.bashrc &" % id);
Does somebody here have an experience with this problem?
Thanks a lot!
alessandro
More information about the Tkinter-discuss
mailing list