Module/lib for controlling a terminal program using redrawing?

2015-03-14 Thread Jason Heeris
I am trying to automate the use of some old, in-house terminal-based
programs that use screen redrawing for their interface. This includes
single line redrawing (eg. using '\r' and overwriting), complete screen
clearing, and fine-grained cursor movement and overwriting (probably not
all in the same program at the same time though).

Is there a module/library that can help me with this?

I know of pexpect, but that seems more oriented towards line-by-line
prompts that don't involve redraws (eg. login prompt, then password prompt
on a new line). Think instead of trying to automate applications like
emacs, aptitude or even nethack that redraw sections of the screen without
making the terminal scroll.

This automation requires more than just sending a set of keystrokes, but
also reading what is displayed on screen and making decisions based up on
that.

Is there a library that can abstract the received redrawing activity so I
don't have to even know if the application has, eg. used a carriage return
or some other kind of cursor movement? Is there a way to just ask "if this
were to be run in an ANSI terminal, what would be in each cell?"

Python 2 or 3 are both fine, external packages are fine, but it has to work
on Linux (eg. Ubuntu 14.04 or later, Debian Wheezy or later).

Any pointers appreciated.

Cheers,
Jason
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Module/lib for controlling a terminal program using redrawing?

2015-03-14 Thread Jason Heeris
Yes, Paul Rubin had it right: I hadn't thought of the term "screen
scraper," but that might help my searching.

On 15 March 2015 at 05:50, Terry Reedy  wrote:
>
> Perhaps you can use the guts of a terminal emulation program, removing
the part that displays the interpreted stream (a 24 x 80 array) on the
screen.  Searching 'python terminal emulation' returns these

Thanks for those results. I also discovered that someone wrote a Python
ANSI terminal scraper originally for use with Nethack:
https://github.com/helgefmi/ansiterm (although it seems generic enough).

Cheers,
Jason
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python+Glade+Gtk tutorial?

2015-03-16 Thread Jason Heeris
Warning: I'm only going to answer half of your questions :)

I haven't built any GTK2/3 app in a while, but hopefully others here can
address your other questions (although you might have better luck on the
Python/GTK mailing list when it comes to finding a good tutorial, etc.)

On 17 March 2015 at 03:13, Dave Farrance <
[email protected]> wrote:
> A web-search told me that Glade seems to be most peoples choice (over
> QT-Designer) for a GUI builder.  So even though I use a KDE desktop
> (Kubuntu 14.10), I decided to try Glade.

In terms of toolkit bindings, (a) I prefer GTK, but (b) it's impossible to
tell what the greater proportion of people using one vs. the other is. Or
if they're wise to do so. Are there more Google hits/SO questions because
it's harder to use? Or because everyone loves to use it? (And so on...)

A recent comment on my SO answer to a similar question claims PyQT/PySide
is a good way to go, with a couple of links there you might find
interesting: http://stackoverflow.com/a/3290724/188535

I wouldn't stress over it though; you can give yourself a headache trying
to decide between frameworks you've never developed in. Try one, commit to
developing at least some proficiency in it, and then try the other.

> "from gi.repository import Gtk, Gdk, GObject, Pango" etc...
>
> ... I get, in effect, the libraries used in Gnome-3 even with python2?

Yes. The GTK and Python versions are independent. You can make GTK3 apps
with either Python 2 or 3. It's purely coincidence that Python 3 and GTK3
came out around the same time.

Going the other way, Gnome 3 still includes some GTK2 apps, but I think
you'd get little sympathy for starting a *new* app in GTK2 instead of 3.

> Am I on the right track now?  Glade is a good choice for GUI building? And
> even though I'm using Python2, I should be ignoring all examples turned up
> by searching for "PyGTK" because they all seem to be GTK+2 and obsolete?

Glade is good, although eventually you learn the lesson that it's not going
to give you 100% control over your UI — there are some things you are
better off doing in your app setup code.

And yes, I'd recommend ignoring anything labelled PyGTK.

— Jason
-- 
https://mail.python.org/mailman/listinfo/python-list