Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #53227 > unrolled thread

Python TUI that will work on DOS/Windows and Unix/Linux

Started by"James Harris" <james.harris.1@gmail.com>
First post2013-08-29 09:12 +0100
Last post2013-09-11 17:18 +0100
Articles 5 — 3 participants

Back to article view | Back to comp.lang.python


Contents

  Python TUI that will work on DOS/Windows and Unix/Linux "James Harris" <james.harris.1@gmail.com> - 2013-08-29 09:12 +0100
    Re: Python TUI that will work on DOS/Windows and Unix/Linux "James Harris" <james.harris.1@gmail.com> - 2013-09-04 12:41 +0100
      Re: Python TUI that will work on DOS/Windows and Unix/Linux Joost Molenaar <j.j.molenaar@gmail.com> - 2013-09-11 00:50 +0200
      Re: Python TUI that will work on DOS/Windows and Unix/Linux Michael Torrie <torriem@gmail.com> - 2013-09-10 18:06 -0600
        Re: Python TUI that will work on DOS/Windows and Unix/Linux "James Harris" <james.harris.1@gmail.com> - 2013-09-11 17:18 +0100

#53227 — Python TUI that will work on DOS/Windows and Unix/Linux

From"James Harris" <james.harris.1@gmail.com>
Date2013-08-29 09:12 +0100
SubjectPython TUI that will work on DOS/Windows and Unix/Linux
Message-ID<kvmvpg$g96$1@dont-email.me>
Am looking for a TUI (textual user interface) mechanism to allow a Python 
program to create and update a display in text mode. For example, if a 
command prompt was sized 80x25 it would be made up of 80 x 25 = 2000 
characters. The Python program would need to be able to write to any of 
those 2000 characters at any time though in practice the display would 
normally be arranged by dividing it up into non-overlapping rectangular 
regions.

I have seen that there are various libraries: urwid, newt, console, dialog 
etc. But they seem to be either for Unix or for DOS, not for both. I am 
looking for a library that will run under either.

Furthermore, some libraries are complex, providing widgets of all kinds. I 
am looking for something much simpler and the lighter-weight it is the 
better. At least at this stage I pretty much just want to divide the screen 
up into panels.

Input from keyboard would be essential. Input from a mouse would be nice to 
have.

Especially if you have had a similar requirement in the past but even if 
not, is there any cross-platform system you would recommend?

James

[toc] | [next] | [standalone]


#53619

From"James Harris" <james.harris.1@gmail.com>
Date2013-09-04 12:41 +0100
Message-ID<l0768i$v2$1@dont-email.me>
In reply to#53227
"James Harris" <james.harris.1@gmail.com> wrote in message 
news:kvmvpg$g96$1@dont-email.me...
> Am looking for a TUI (textual user interface) mechanism to allow a Python 
> program to create and update a display in text mode. For example, if a 
> command prompt was sized 80x25 it would be made up of 80 x 25 = 2000 
> characters. The Python program would need to be able to write to any of 
> those 2000 characters at any time though in practice the display would 
> normally be arranged by dividing it up into non-overlapping rectangular 
> regions.
>
> I have seen that there are various libraries: urwid, newt, console, dialog 
> etc. But they seem to be either for Unix or for DOS, not for both. I am 
> looking for a library that will run under either.

In case anyone else is following this, people have emailed me directly 
suggesting ncurses, pdcurses and these:

Pygcurse (http://inventwithpython.com/pygcurse/)
UniCurses (http://sourceforge.net/projects/pyunicurses/)

Naturally, all of these are centred on curses. I have been reading up on it 
and must say that the whole curses approach seems rather antiquated. I 
appreciate the suggestions and they may be what I need to do but from what I 
have seen of curses it was designed principally to provide common ways to 
control cursor-based terminals. That was a-la-mode in the days when we had 
terminals with different cursor control strings and I remember programming 
VT100 and VT52 monitors or terminals like them. But now it seems cumbersome.

I haven't thought too much about it so this is not a design proposal but it 
might be better to divide a display up into non-overlapping windows and 
treat each one separately. Writes to one would not be able to affect the 
others. A given window could allow writes to fixed locations or could behave 
as a glass teletype, writing to the bottom of the window and scrolling as 
needed, or could behave as a viewing port into a data structure. Something 
like that may be more useful to a programmer even if it has to use curses 
underneath because that's all that the OS provides.

James

[toc] | [prev] | [next] | [standalone]


#53932

FromJoost Molenaar <j.j.molenaar@gmail.com>
Date2013-09-11 00:50 +0200
Message-ID<mailman.228.1378853428.5461.python-list@python.org>
In reply to#53619

[Multipart message — attachments visible in raw view] — view raw

Have you looked at Blessings?

I never tried it, but the API seems much cleaner than Curses.

https://pypi.python.org/pypi/blessings/

--
Joost Molenaar

[toc] | [prev] | [next] | [standalone]


#53934

FromMichael Torrie <torriem@gmail.com>
Date2013-09-10 18:06 -0600
Message-ID<mailman.229.1378858009.5461.python-list@python.org>
In reply to#53619
On 09/04/2013 05:41 AM, James Harris wrote:
> Naturally, all of these are centred on curses. I have been reading up on it 
> and must say that the whole curses approach seems rather antiquated. I 
> appreciate the suggestions and they may be what I need to do but from what I 
> have seen of curses it was designed principally to provide common ways to 
> control cursor-based terminals. That was a-la-mode in the days when we had 
> terminals with different cursor control strings and I remember programming 
> VT100 and VT52 monitors or terminals like them. But now it seems cumbersome.

Well it's the same problem you're trying to solve today.  You've got a
text console with a cursor you can move around and print out text.
Besides with any modern operation system you can't write directly to the
screen anyway, like we used to back in the DOS days when we poked
directly into video memory.

> I haven't thought too much about it so this is not a design proposal but it 
> might be better to divide a display up into non-overlapping windows and 
> treat each one separately. Writes to one would not be able to affect the 
> others. A given window could allow writes to fixed locations or could behave 
> as a glass teletype, writing to the bottom of the window and scrolling as 
> needed, or could behave as a viewing port into a data structure. Something 
> like that may be more useful to a programmer even if it has to use curses 
> underneath because that's all that the OS provides.

A toolkit (that's old, arguably), that might help you is TVision, a port
of the old Turbo Vision library that formed the foundation for Borland's
old DOS IDEs back in the day (check wikipedia).  And it looked quite
beautiful back then, actually.  There is a Python binding for it here:

https://pypi.python.org/pypi/PyTVision

The original C++ is here:
http://tvision.sourceforge.net/

TVision does run on DOS, Windows console, and of course Unix, though
you'd need the appropriate shared library.

Or you could write your own, based on top of something like curses.

[toc] | [prev] | [next] | [standalone]


#53977

From"James Harris" <james.harris.1@gmail.com>
Date2013-09-11 17:18 +0100
Message-ID<l0q54r$ss8$1@dont-email.me>
In reply to#53934
"Michael Torrie" <torriem@gmail.com> wrote in message 
news:mailman.229.1378858009.5461.python-list@python.org...

...

> A toolkit (that's old, arguably), that might help you is TVision, a port
> of the old Turbo Vision library that formed the foundation for Borland's
> old DOS IDEs back in the day (check wikipedia).  And it looked quite
> beautiful back then, actually.  There is a Python binding for it here:
>
> https://pypi.python.org/pypi/PyTVision

That looks very good.

For the record, I have been emailed about npyscreen and urwid. And I have 
found a hex editor with the kind of interface I had in mind. Here are some 
links for anyone else who is interested.

  http://www.sigala.it/sergio/tvision/images.html
  http://www.npcole.com/npyscreen/
  http://excess.org/urwid/examples.html
  http://www.hexedit.com/hex-edit-shots.htm

James

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web