Re: [Tutor] Curses example on Linux?

2005-08-12 Thread Alan Gauld

"Hossein Movahhedian" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> "ky = chr(msvcrt.getch())". The other problem is that when
> the program is finished the previous terminal state is not
> restored (I am using xterm on Linux).

OK, experimenting with the Linux stty command shows that

$ stty echo -nl

will restore the terminal to the proper settings.
I still haven't figured out how to do it from inside
python/curses - that's my next step!

Alan G. 



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Curses example on Linux?

2005-08-09 Thread Alan G
> "ky = chr(msvcrt.getch())". The other problem is that when
> the program is finished the previous terminal state is not
> restored (I am using xterm on Linux).

Yep, and that applies to my cygwin terminal too. I think there 
is a setty command you can issue that fixres this but since I 
hardly ever use curses I can't recall what it is - anyone???

>   Finally, I noticed a typo in the example "class Message" in
> section Object Oriented Programming. __init__ is written __inti__
> in "def __inti__(self, aString):".

OK, Thanks. If you find any more typos send them to me via 
the mail me link at the bottom of each page - it saves bandwidth 
on the tutor list (and my embarrasment :-)

BTW Which version of the tutor are you reading? The inti bug 
seems to have been fixed in the latest English version...

Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Curses example on Linux?

2005-08-09 Thread Hossein Movahhedian



   Dear Alan
   Hi,

   First of all let me thank you very much for that excellent
 tutorial. As a Python beginner, I learned many things from that.
   As I have mentioned in my previous message to this list, in
 that example I had to replace "ky = msvcrt.getch()" with
 "ky = chr(msvcrt.getch())". The other problem is that when
 the program is finished the previous terminal state is not
 restored (I am using xterm on Linux).
   Finally, I noticed a typo in the example "class Message" in
 section Object Oriented Programming. __init__ is written __inti__
 in "def __inti__(self, aString):".

Regards,
Hossein

On Tue, 9 Aug 2005, Alan G <[EMAIL PROTECTED]> wrote:

> >>I have copied the following example from "Learning to Program by
> >> Alan
> >>  Gauld (section: Event Driven Programming)". To run it on Linux
> >>  (Redhat 8.0; Python 2.4) the tutorial says to replace 'msvcrt'
> >>  with 'curses.stdscr'.
>
> I thought I'd fixed that fault.
>
> The sequence should be:
>
> import curses
> mscvrt = curses.initscr()
> mscvcrt.getch()
>
>
> I will make the changes and upload the fixed file as soon as possible.
>
>
> Thanks for bringing it up.
>
> Alan G
> Author of the Learn to Program web tutor
> http://www.freenetpages.co.uk/hp/alan.gauld
>
> >
> >
> > Hi Hossein,
> >
> >
> > According to:
> >
> >http://www.amk.ca/python/howto/curses/
> >
> >
> > Alan probably meant to say to replace:
> >
> > ##
> > import msvcrt
> > ##
> >
> > with:
> >
> > ##
> > import curses
> > msvcrt = curses.initscr()
> > ##
> >
> > as a quick hack to replace 'msvcrt' with something that works on
> > Linux.
> >
> >
> > It sounded that you wanted to look at other examples of curses
> > programming?  A long time ago, I wrote a quick-and-dirty demo
> > program that
> > uses curses here:
> >
> >http://hkn.eecs.berkeley.edu/~dyoo/python/circularwriting.py
> >
> >
> > Good luck to you!
> >
> >
> >
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Curses example on Linux?

2005-08-09 Thread Hossein Movahhedian

   Dear Danny
   Hi,
   Many thanks for your help and especially the references in your
reply. Now the code works fine.
   BTW, I had to replace "ky = msvcrt.getch()" with
 "ky = chr(msvcrt.getch())".

Regards,
Hossein

On Mon, 8 Aug 2005, Danny Yoo <[EMAIL PROTECTED]> wrote:

>
>
> On Mon, 8 Aug 2005, Hossein Movahhedian wrote:
>
> >I have copied the following example from "Learning to Program by Alan
> >  Gauld (section: Event Driven Programming)". To run it on Linux
> >  (Redhat 8.0; Python 2.4) the tutorial says to replace 'msvcrt'
> >  with 'curses.stdscr'.
>
>
> Hi Hossein,
>
>
> According to:
>
> http://www.amk.ca/python/howto/curses/
>
>
> Alan probably meant to say to replace:
>
> ##
> import msvcrt
> ##
>
> with:
>
> ##
> import curses
> msvcrt = curses.initscr()
> ##
>
> as a quick hack to replace 'msvcrt' with something that works on Linux.
>
>
> It sounded that you wanted to look at other examples of curses
> programming?  A long time ago, I wrote a quick-and-dirty demo program that
> uses curses here:
>
> http://hkn.eecs.berkeley.edu/~dyoo/python/circularwriting.py
>
>
> Good luck to you!
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Curses example on Linux?

2005-08-09 Thread Alan G
>>I have copied the following example from "Learning to Program by 
>> Alan
>>  Gauld (section: Event Driven Programming)". To run it on Linux
>>  (Redhat 8.0; Python 2.4) the tutorial says to replace 'msvcrt'
>>  with 'curses.stdscr'.

I thought I'd fixed that fault.

The sequence should be:

import curses
mscvrt = curses.initscr()
mscvcrt.getch()


I will make the changes and upload the fixed file as soon as possible.


Thanks for bringing it up.

Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld

>
>
> Hi Hossein,
>
>
> According to:
>
>http://www.amk.ca/python/howto/curses/
>
>
> Alan probably meant to say to replace:
>
> ##
> import msvcrt
> ##
>
> with:
>
> ##
> import curses
> msvcrt = curses.initscr()
> ##
>
> as a quick hack to replace 'msvcrt' with something that works on 
> Linux.
>
>
> It sounded that you wanted to look at other examples of curses
> programming?  A long time ago, I wrote a quick-and-dirty demo 
> program that
> uses curses here:
>
>http://hkn.eecs.berkeley.edu/~dyoo/python/circularwriting.py
>
>
> Good luck to you!
>
>
> 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Curses example on Linux?

2005-08-08 Thread Danny Yoo


On Mon, 8 Aug 2005, Hossein Movahhedian wrote:

>I have copied the following example from "Learning to Program by Alan
>  Gauld (section: Event Driven Programming)". To run it on Linux
>  (Redhat 8.0; Python 2.4) the tutorial says to replace 'msvcrt'
>  with 'curses.stdscr'.


Hi Hossein,


According to:

http://www.amk.ca/python/howto/curses/


Alan probably meant to say to replace:

##
import msvcrt
##

with:

##
import curses
msvcrt = curses.initscr()
##

as a quick hack to replace 'msvcrt' with something that works on Linux.


It sounded that you wanted to look at other examples of curses
programming?  A long time ago, I wrote a quick-and-dirty demo program that
uses curses here:

http://hkn.eecs.berkeley.edu/~dyoo/python/circularwriting.py


Good luck to you!

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor