embedding in Tkinter

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

embedding in Tkinter

Alessandro Magni-2
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
_______________________________________________
Tkinter-discuss mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/tkinter-discuss
Reply | Threaded
Open this post in threaded view
|

Re: embedding in Tkinter

John McMonagle-5
On 06/09/11 22:24, Alessandro Magni wrote:

> 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!

I've modified your little example above with some success:

from Tkinter import *
import os

root = Tk()
termf = Frame(root, height=200, width=400)
termf.pack(fill=BOTH, expand=YES)
wid = termf.winfo_id()
os.system('xterm -into %d -geometry 400x200 -e /root/.bashrc&' % wid)

root.mainloop()


Happy experimenting,

John

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

_______________________________________________
Tkinter-discuss mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/tkinter-discuss
Reply | Threaded
Open this post in threaded view
|

Re: embedding in Tkinter

Cameron Laird-2
On Wed, Sep 07, 2011 at 09:44:21AM +1000, John McMonagle wrote:
> On 06/09/11 22:24, Alessandro Magni wrote:
> > 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've modified your little example above with some success:
>
> from Tkinter import *
> import os
>
> root = Tk()
> termf = Frame(root, height=200, width=400)
> termf.pack(fill=BOTH, expand=YES)
> wid = termf.winfo_id()
> os.system('xterm -into %d -geometry 400x200 -e /root/.bashrc&' % wid)
>
> root.mainloop()
                        .
                        .
                        .
Alessandro, when you write "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"
and "... it doesn't work", I am unsure of your meaning.  John
answered what I understand of your question about Tkinter coding
well; do you also want help communicating between the xterm's
$SHELL and the Python application, or do you have what you need
for that aspect, already?
_______________________________________________
Tkinter-discuss mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/tkinter-discuss