On Sun, 22 Oct 2017 14:34:31 +0100, T M Smith wrote:
>> On Sat, 21 Oct 2017 17:11:47 -0400, rickman wrote:
>
>>> T M Smith wrote on 10/21/2017 4:04 PM:
>>>> I am sure this is elementary to most but bear with me please.
>>>> I am using Raspbian on a pi. How does one get a reading to print on
>>>> screen in the same place on a continueing basis rather than printing
>>>> on a new line and scrolling.
>>>
>>> Are you writing your own program? What is the text coming from?
>>>
>>> If you just want to update the bottom line the program should send CR
>>> but no LF. If you want the text to appear at a specific location on
>>> the screen, you can send ANSI codes I believe, but I'm not totally
>>> clear on how Linux does it. But I believe each window is essentially
>>> a terminal emulator from the perspective of the program running in it.
>>>
>> Yep. Each console window is effectively a 24 x 80 colour screen. What
>> language is the program written it? That's relevant because many
>> languages have their own terminal management packages:
>
>> - Python has at least two - Java has Swing and FX packages for
>> displaying non-image data as well as
>> image manipulation and display packages
>> - C has curses for writing editors like vi, etc, i.e. its meant for
>> giving you fa-ne control of where you can write text to and receive
>> input from a (typically) 24x80 character-mode terminal. There's also
>> and also Gtk+ package for building 2D and 3D graphical displays.
>
>> GTK+ and Open GL support applications written in a variety of
>> languages.
>
>> All of these have a fairly steep learning curve if you haven't used any
>> of them, but the concepts they use are all fairly similar, so once
>> you've understood one, using different graphical/terminal packages
>> becomes a lot easier.
>
>> I've implemented a version of Curses for Java, using the information
>> and API description in "Programming with Curses" (O'Reilly) partly
>> because I could and partly to convince myself that I understood Curses
>> well enough to do it.
> I am altering a python program and just wish to display readings of
> temperature etc. in the same place on screen after each update.
>
Is this to be run in a GUI window or on a text-mode console?
GUI window: it seems that Tkinter is the way to go:
=========== http://wiki.python.org/moin/TkInter
as it seems to be the de-facto Python GUI package.
Console: there's a version of Curses ported to Python
======== IMO this is the way to go for a text-mode console,
regardless of whether you're running the program in a
console window on an Raspbian desktop or over an SSH
session connected to a headless RPi.
Or, of course, you can try (in pseudocode):
read initial temp value from sensor
repeat
write temp to console WITHOUT a newline
read temp from sensor
write backspaces to erase the last temp
forever
but using Tkinter or Curses will let you paint a nicer screen with
a title and a captioned place to output the temp reading
as well as a way to input a QUIT command. In addition, you'll learn a
skill that's likely to be useful for other projects.
Also, though probably not useful here, take a look at xmessage, which is
a convenient way to pop up messages on the desktop and input text by
clicking buttons. It is designed to be use in shell scripts but could
also be executed from any language that can run commands. Here's an
example (tested):
echo "Can you read this?" | \
xmessage -buttons Yes,No -center -timeout 5 -print -file -
... which could do pretty much what you want: if called from a
temperature sampling loop. Timeout would control the temperature sampling
rate and using a single "Quit" button would be a clean way to stop the
controlling program.
--
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)
|