Re: [pygtk] A question for Python Gurus

1999-11-12 Thread James Henstridge

zvt supports ANSI colour escape sequences.  If you pass the escape
sequences to the zvt widget, it will render them correctly.  There should
be lots of docs on this somewhere on the net.

James.

--
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


On Fri, 12 Nov 1999, Hassan Aurag wrote:

> 
> 
> >>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<<
> 
> On 11/12/99, 5:52:42 AM, Andreas Degert <[EMAIL PROTECTED]> wrote 
> regarding Re: [pygtk] A question for Python Gurus:
> 
> 
> > Hassan Aurag <[EMAIL PROTECTED]> writes:
> 
> > >  I am still learning python, however in 'Learning Python' they give an
> > > example about how to redefine the print function using sys.stdout
> > > methods and say one can do the same with sys.stdin. So I thought it
> > > might be easy!
> 
> > Of course you can redirect stdin like this:
> 
> > sys.stdin = open("whatever")
> 
> > Or just define a class providing the needed methods (python will
> > complain about what is missing...) and assign an instance to
> > sys.stdin.
> 
> > Maybe you can use zvt to do the coloring, but then its not the python
> > program which does that, what I thought was what you wanted.
> 
>   Ok, then how does one tell zvt to do the coloring! The API docs say 
> yes you can, but not how afaik.
> Looking at the functions in zvt.py didn't help me either!
> 
>   In any case, whatever one chooses, what I'd like to understand (if 
> it is possible for me to do so) is how raw_input works or any other 
> input thing! To be precise I'd love to pass input through a filter 
> before displaying it! Which function does that, which method? Do I 
> need to use something other than raw_input but can mimic it?
> 
>  Thanks again
> 
> 
> 
> 
> 
> To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]
> 

To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]



Re: [pygtk] A question for Python Gurus

1999-11-12 Thread Hassan Aurag



>>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<<

On 11/12/99, 5:52:42 AM, Andreas Degert <[EMAIL PROTECTED]> wrote 
regarding Re: [pygtk] A question for Python Gurus:


> Hassan Aurag <[EMAIL PROTECTED]> writes:

> >  I am still learning python, however in 'Learning Python' they give an
> > example about how to redefine the print function using sys.stdout
> > methods and say one can do the same with sys.stdin. So I thought it
> > might be easy!

> Of course you can redirect stdin like this:

> sys.stdin = open("whatever")

> Or just define a class providing the needed methods (python will
> complain about what is missing...) and assign an instance to
> sys.stdin.

> Maybe you can use zvt to do the coloring, but then its not the python
> program which does that, what I thought was what you wanted.

  Ok, then how does one tell zvt to do the coloring! The API docs say 
yes you can, but not how afaik.
Looking at the functions in zvt.py didn't help me either!

  In any case, whatever one chooses, what I'd like to understand (if 
it is possible for me to do so) is how raw_input works or any other 
input thing! To be precise I'd love to pass input through a filter 
before displaying it! Which function does that, which method? Do I 
need to use something other than raw_input but can mimic it?

 Thanks again





To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]



Re: [pygtk] A question for Python Gurus

1999-11-12 Thread Andreas Degert

Hassan Aurag <[EMAIL PROTECTED]> writes:

>  I am still learning python, however in 'Learning Python' they give an 
> example about how to redefine the print function using sys.stdout 
> methods and say one can do the same with sys.stdin. So I thought it 
> might be easy!

Of course you can redirect stdin like this:

sys.stdin = open("whatever")

Or just define a class providing the needed methods (python will
complain about what is missing...) and assign an instance to
sys.stdin.

Maybe you can use zvt to do the coloring, but then its not the python
program which does that, what I thought was what you wanted.

> Looks like no, or maybe I need to contact one of the authors and beg 
> them to give an example!
> 
> 
>  Thank you for your help!
>  
> >>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<<
> 
> On 11/6/99, 11:57:31 AM, Andreas Degert <[EMAIL PROTECTED]> wrote 
> regarding Re: [pygtk] A question for Python Gurus:
> 
> 
> > Hassan Aurag <[EMAIL PROTECTED]> writes:
> 
> > >  Hi,
> > >
> > > My question is simple but I can't yet answer it myself. I am still at
> > > the point where I use 'Learning Python'.
> > >
> > > Ok, so I have a terminal and I want to catch the input, and I am not
> > > talking about raw_input.
> > >
> > > I am talking about sys.stdin
> > >
> > > It seems one can override sys.stdout and sys.stdin to redefine in the
> > > first case the print method and the second case the read method.
> > >
> > > The problem is I don't know how to use them. My goal is to color input
> > > depending on text input, eg: in 'def f(x): return x' I want def and
> > > return to be colored. I know how to color the string, but I don't know
> > > how to make sys.stdin color it! Same thing for sys.stdout where I want
> > > it in some cases to format the stuff in some way!
> 
> > not quite sure how you want to make stdin eat colors... :))
> 
> > what you want is direct terminal control, e.g. with the curses module
> > of python, though i don't think this module is properly documented
> > (you'd have to use the curses documentation and do an import curses;
> > dir(curses); ...).
> 
> > If its only for output on a specific terminal, you can directly send
> > escape sequences to get colours (to get this for input too you can't
> > use local echo on the terminal but have to do the echo yourself).
> 
> > IMHO if you are still learning python try to solve some other problems
> > first...
> 
> > > Any help is appreciated, and please a small example, like
> > > def read():
> > > return whatever
> > >
> > > Also, my app is a child process of a zvt (done by fork). Now from
> > > whithin the app I want to call a parent's method (in this case, get
> > > _size or something to get size of terminal) and since people can
> > > resize the terminal I want it to be checked dynamically. How do I do
> > > this? Do I get the pid of parent and call its method like:
> > > getppid().getsize() or something?
> 
> > no. the ppid is just an integer id, and what you need is some form of
> > ipc (inter process communication). In this case you get the SIGWINCH
> > signal when the size changes, and you can use terminal ioctls. But
> > before trying something like this read a good book about Unix.
> 
> > ciao
> > Andreas
> > To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]
> 
> 
> 
> To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]
To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]



Re: [pygtk] A question for Python Gurus

1999-11-11 Thread Hassan Aurag


 I am still learning python, however in 'Learning Python' they give an 
example about how to redefine the print function using sys.stdout 
methods and say one can do the same with sys.stdin. So I thought it 
might be easy!
Looks like no, or maybe I need to contact one of the authors and beg 
them to give an example!


 Thank you for your help!
 
>>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<<

On 11/6/99, 11:57:31 AM, Andreas Degert <[EMAIL PROTECTED]> wrote 
regarding Re: [pygtk] A question for Python Gurus:


> Hassan Aurag <[EMAIL PROTECTED]> writes:

> >  Hi,
> >
> > My question is simple but I can't yet answer it myself. I am still at
> > the point where I use 'Learning Python'.
> >
> > Ok, so I have a terminal and I want to catch the input, and I am not
> > talking about raw_input.
> >
> > I am talking about sys.stdin
> >
> > It seems one can override sys.stdout and sys.stdin to redefine in the
> > first case the print method and the second case the read method.
> >
> > The problem is I don't know how to use them. My goal is to color input
> > depending on text input, eg: in 'def f(x): return x' I want def and
> > return to be colored. I know how to color the string, but I don't know
> > how to make sys.stdin color it! Same thing for sys.stdout where I want
> > it in some cases to format the stuff in some way!

> not quite sure how you want to make stdin eat colors... :))

> what you want is direct terminal control, e.g. with the curses module
> of python, though i don't think this module is properly documented
> (you'd have to use the curses documentation and do an import curses;
> dir(curses); ...).

> If its only for output on a specific terminal, you can directly send
> escape sequences to get colours (to get this for input too you can't
> use local echo on the terminal but have to do the echo yourself).

> IMHO if you are still learning python try to solve some other problems
> first...

> > Any help is appreciated, and please a small example, like
> > def read():
> > return whatever
> >
> > Also, my app is a child process of a zvt (done by fork). Now from
> > whithin the app I want to call a parent's method (in this case, get
> > _size or something to get size of terminal) and since people can
> > resize the terminal I want it to be checked dynamically. How do I do
> > this? Do I get the pid of parent and call its method like:
> > getppid().getsize() or something?

> no. the ppid is just an integer id, and what you need is some form of
> ipc (inter process communication). In this case you get the SIGWINCH
> signal when the size changes, and you can use terminal ioctls. But
> before trying something like this read a good book about Unix.

> ciao
> Andreas
> To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]



To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]



Re: [pygtk] A question for Python Gurus

1999-11-07 Thread Hassan Aurag




 Ok,

Can someone please explain how to use and what is it one uses 
match_add in zvt.py. It looks like some highlight mask but I can't 
figure the syntax.

 What is regex? I mean can I use something like '\wdef\w', but then 
what is highlight mask??

 Does it solve my problem below?!

>>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<<

On 11/6/99, 11:57:31 AM, Andreas Degert <[EMAIL PROTECTED]> wrote 
regarding Re: [pygtk] A question for Python Gurus:


> Hassan Aurag <[EMAIL PROTECTED]> writes:

> >  Hi,
> >
> > My question is simple but I can't yet answer it myself. I am still at
> > the point where I use 'Learning Python'.
> >
> > Ok, so I have a terminal and I want to catch the input, and I am not
> > talking about raw_input.
> >
> > I am talking about sys.stdin
> >
> > It seems one can override sys.stdout and sys.stdin to redefine in the
> > first case the print method and the second case the read method.
> >
> > The problem is I don't know how to use them. My goal is to color input
> > depending on text input, eg: in 'def f(x): return x' I want def and
> > return to be colored. I know how to color the string, but I don't know
> > how to make sys.stdin color it! Same thing for sys.stdout where I want
> > it in some cases to format the stuff in some way!

> not quite sure how you want to make stdin eat colors... :))

> what you want is direct terminal control, e.g. with the curses module
> of python, though i don't think this module is properly documented
> (you'd have to use the curses documentation and do an import curses;
> dir(curses); ...).

> If its only for output on a specific terminal, you can directly send
> escape sequences to get colours (to get this for input too you can't
> use local echo on the terminal but have to do the echo yourself).

> IMHO if you are still learning python try to solve some other problems
> first...

> > Any help is appreciated, and please a small example, like
> > def read():
> > return whatever
> >
> > Also, my app is a child process of a zvt (done by fork). Now from
> > whithin the app I want to call a parent's method (in this case, get
> > _size or something to get size of terminal) and since people can
> > resize the terminal I want it to be checked dynamically. How do I do
> > this? Do I get the pid of parent and call its method like:
> > getppid().getsize() or something?

> no. the ppid is just an integer id, and what you need is some form of
> ipc (inter process communication). In this case you get the SIGWINCH
> signal when the size changes, and you can use terminal ioctls. But
> before trying something like this read a good book about Unix.

> ciao
> Andreas
> To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]



To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]



Re: [pygtk] A question for Python Gurus

1999-01-04 Thread Andreas Degert

Hassan Aurag <[EMAIL PROTECTED]> writes:

>  Hi,
> 
> My question is simple but I can't yet answer it myself. I am still at 
> the point where I use 'Learning Python'.
> 
> Ok, so I have a terminal and I want to catch the input, and I am not 
> talking about raw_input.
> 
> I am talking about sys.stdin
> 
> It seems one can override sys.stdout and sys.stdin to redefine in the 
> first case the print method and the second case the read method.
> 
> The problem is I don't know how to use them. My goal is to color input 
> depending on text input, eg: in 'def f(x): return x' I want def and 
> return to be colored. I know how to color the string, but I don't know 
> how to make sys.stdin color it! Same thing for sys.stdout where I want 
> it in some cases to format the stuff in some way!

not quite sure how you want to make stdin eat colors... :))

what you want is direct terminal control, e.g. with the curses module
of python, though i don't think this module is properly documented
(you'd have to use the curses documentation and do an import curses;
dir(curses); ...).

If its only for output on a specific terminal, you can directly send
escape sequences to get colours (to get this for input too you can't
use local echo on the terminal but have to do the echo yourself).

IMHO if you are still learning python try to solve some other problems
first...

> Any help is appreciated, and please a small example, like
> def read():
>   return whatever
> 
> Also, my app is a child process of a zvt (done by fork). Now from 
> whithin the app I want to call a parent's method (in this case, get 
> _size or something to get size of terminal) and since people can 
> resize the terminal I want it to be checked dynamically. How do I do 
> this? Do I get the pid of parent and call its method like: 
> getppid().getsize() or something?

no. the ppid is just an integer id, and what you need is some form of
ipc (inter process communication). In this case you get the SIGWINCH
signal when the size changes, and you can use terminal ioctls. But
before trying something like this read a good book about Unix.

ciao
Andreas
To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]



[pygtk] A question for Python Gurus

1999-01-04 Thread Hassan Aurag

 Hi,

My question is simple but I can't yet answer it myself. I am still at 
the point where I use 'Learning Python'.

Ok, so I have a terminal and I want to catch the input, and I am not 
talking about raw_input.

I am talking about sys.stdin

It seems one can override sys.stdout and sys.stdin to redefine in the 
first case the print method and the second case the read method.

The problem is I don't know how to use them. My goal is to color input 
depending on text input, eg: in 'def f(x): return x' I want def and 
return to be colored. I know how to color the string, but I don't know 
how to make sys.stdin color it! Same thing for sys.stdout where I want 
it in some cases to format the stuff in some way!

Any help is appreciated, and please a small example, like
def read():
return whatever

Also, my app is a child process of a zvt (done by fork). Now from 
whithin the app I want to call a parent's method (in this case, get 
_size or something to get size of terminal) and since people can 
resize the terminal I want it to be checked dynamically. How do I do 
this? Do I get the pid of parent and call its method like: 
getppid().getsize() or something?


 Thank you for your time

H. Aurag




To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]