On Sun, 22 Oct 2017 13:10:39 -0400, Dennis Lee Bieber wrote:
> On Sun, 22 Oct 2017 14:34:31 +0100, T M Smith
> declaimed the following:
>
>> I am altering a python program and just wish to display readings of
>>temperature etc. in the same place on screen after each update.
>>
> You'd probably get better suggestions by showing the relevant
snippet
> of existing code.
>
> Since your original post implies the existing program is
scrolling, I'm
> going to assume it is a simple console application (I don't see anyone
> going through the effort of creating a GUI application with a scrolling
> output, where a single line text widget would suffice).
>
> -=-=-=-=-
> """
> Simple demo for scroll vs non-scroll (Python 2.7, hence xrange and
> paren-less print)
> """
>
> import sys import time
>
> if "scroll" in sys.argv:
> print print for x in xrange(100):
> print "Pseudo-Temperature: %10.3f" % (x * 3.14159 - 25.5)
> time.sleep(1)
> elif "overwrite" in sys.argv:
> print print for x in xrange(100):
> sys.stdout.write("\rPseudo-Temperature: %10.3f"
> % (x * 3.14159 - 25.5))
> time.sleep(1)
> else:
> print "\nPlease supply either 'scroll' or 'overwrite' on the command
> line"
>
>
> -=-=-=-=-
> C:\Users\Wulfraed\Documents\Python Progs>so.py
>
This solution doesn't seem to be OS-agnostic, unfortunately.
On my system, Fedora 25 with Python 2.7.13, 'scroll' works as expected,
but 'overwrite' doesn't display anything. Since that looks as if you ran
it on some flavour of Windows, does it work as expected on a Raspbian box?
--
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)
|