running an application within an text widget 
Author Message
 running an application within an text widget

I have an application that is going to be sending multiple lines to stdout
in a menu format such as:

        1) do something
        2) do something else
        3) do something really cool

==>

And each option is going to get take stdin from the user.

What I would like to do is somehow link this application to a tk text
widget such that the menus, the user responses, and the application
output is all controlled and displayed within the text widget i.e. the
menu appears in the widget, the user types his response in the widget,
and the output is displayed in a widget.

Could someone show me how to do something like this using perhaps "sh"
as the application and having it all controlled within the text widget?

thanx for the help,
-tms

--
You can get further with a kind word | You can get further with a kind word
and a gun than a kind word alone.    | and a phaser than a kind word and a gun.
          --al capone                |           -- John Navarra



Fri, 29 Nov 1996 19:54:29 GMT  
 running an application within an text widget
Here is an extremely lame excuse for a shell that you might be able
to build upon.  It runs entirely within a text object called
.fakeshell.  It seems to do the trick for simple operations such as
ls, ps, etc.

Hope this helps!


#! /usr/public/wish -f

set fakeshell [text .fakeshell -height 50]
pack $fakeshell

bind $fakeshell <Return> {Execute $fakeshell}

focus $fakeshell

proc Execute { shell } {

   scan "[$shell index end]" "%d.%d" line char

   set cmd [$shell get $line.0 end]

   set f1 [open |$cmd r]

   while {[gets $f1 line] != -1} {
        $shell insert end "\n\t$line"
   }

   $shell insert end "\n"

   close $f1

Quote:
}


: I have an application that is going to be sending multiple lines to stdout
: in a menu format such as:

:       1) do something
:       2) do something else
:       3) do something really cool

: ==>

: And each option is going to get take stdin from the user.

: What I would like to do is somehow link this application to a tk text
: widget such that the menus, the user responses, and the application
: output is all controlled and displayed within the text widget i.e. the
: menu appears in the widget, the user types his response in the widget,
: and the output is displayed in a widget.

: Could someone show me how to do something like this using perhaps "sh"
: as the application and having it all controlled within the text widget?

: thanx for the help,
: -tms

: --
: You can get further with a kind word | You can get further with a kind word
: and a gun than a kind word alone.    | and a phaser than a kind word and a gun.
:           --al capone                |           -- John Navarra



Sat, 30 Nov 1996 06:31:18 GMT  
 running an application within an text widget

Quote:

>Here is an extremely lame excuse for a shell that you might be able
>to build upon.  It runs entirely within a text object called
>.fakeshell.  It seems to do the trick for simple operations such as
>ls, ps, etc.

>Hope this helps!

Well, this helps a little but it doesn't read any text from stdin.
What I need is a way to display the applications menus in a text
widget, get the users response in the widget, and write the applications
stdout to the widget. If I could run sh inside a text widget, that
would be one example of such an application. But, more simply, if
I could just run some simple shell script like:

#!/bin/sh
echo "What is your name?"
read name
echo "Your name is " $name

inside, the text widget, this would be very helpful.

Thanx for any info,

-tms

--
You can get further with a kind word | You can get further with a kind word
and a gun than a kind word alone.    | and a phaser than a kind word and a gun.
          --al capone                |           -- John Navarra



Sat, 30 Nov 1996 13:42:15 GMT  
 running an application within an text widget

Quote:

> I have an application that is going to be sending multiple lines to stdout
> in a menu format such as:

>    1) do something
>    2) do something else
>    3) do something really cool

> ==>

> And each option is going to get take stdin from the user.

> What I would like to do is somehow link this application to a tk text
> widget such that the menus, the user responses, and the application
> output is all controlled and displayed within the text widget i.e. the
> menu appears in the widget, the user types his response in the widget,
> and the output is displayed in a widget.

> Could someone show me how to do something like this using perhaps "sh"
> as the application and having it all controlled within the text widget?

What you could use for this is expect, an extension to tcl to control interactive
programs which use stdin/stdout. It is written by Don Libes and can be found in
the tcl-archives. I'm currently using it to create a graphical frontend for an
application and it works really well.
If you have any more questions, don't hesitate to contact me.

Cheers,

   Dominik

 -----------------------------------------------------------------------------
  Dominik Zimmermann                            Technische Universitaet Berlin
                                                Sekr. 5-6

     ph: +49-30-314-21762                       10587 Berlin
                                                Germany

         Some people believe that the stars determine their fate;
                I believe in the One who made the stars.



Sat, 30 Nov 1996 16:36:31 GMT  
 running an application within an text widget
|>
|> I have an application that is going to be sending multiple lines to stdout
|> in a menu format such as:
|>
|>   1) do something
|>   2) do something else
|>   3) do something really cool
|>
|> ==>
|>
|> And each option is going to get take stdin from the user.
|>
|> What I would like to do is somehow link this application to a tk text
|> widget such that the menus, the user responses, and the application
|> output is all controlled and displayed within the text widget i.e. the
|> menu appears in the widget, the user types his response in the widget,
|> and the output is displayed in a widget.
|>
|> Could someone show me how to do something like this using perhaps "sh"
|> as the application and having it all controlled within the text widget?

Do I understand it correctly that you want an 'xterm-like' widget ?
I don't know any, but an alternative would be to embed an xterm into
your tk window hierarchy using Sven Delmas'  TkSteal  stuff.
Forget this post if is HAS to be a text widget.

Bert



Sat, 30 Nov 1996 20:44:31 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. application within a text widget

2. Some questions on elided text in the text widget (and a few other text widget questions)

3. Problems Using Dos-commands within an dBase IV 2.0 Application running WIN95

4. Problems Using Dos-commands within an dBase IV 2.0 Application running WIN95

5. Running IDLE from within a Tkinter application

6. HTML widget within a Xmotif application

7. How to run an textmode application within a TCL window

8. Control placement of a button within a text widget

9. tkdnd within a text widget with blinking cursor

10. Color change within a text widget

11. Tkinter question: position cursor within text widget

12. Making different text styles within list widgets

 

 
Powered by phpBB® Forum Software