User Interface Suggestions? (newbie)

Chris Angelico rosuav at gmail.com
Wed Oct 5 10:09:58 EDT 2016


On Thu, Oct 6, 2016 at 12:10 AM, Beverly Howard <bev at bevhoward.com> wrote:
> I'm new to Python, but have three decades of experience with FoxPro and VFP plus I started programming in Basic and still comfortable with that.
>
> I have spent some time with Python and am now fairly familiar with the syntax and functions, but building a user interface has me stopped.
>
> A primary question would be, "What are options for building a display that would update displayed values without scrolling?"
>
> My first goal is to build a program that would interface with a Raspberry Pi to control a heating process.
>

Good question to ask, and thank you for declaring your background.
Also, welcome!

In Python, the simplest and cleanest way to build a user interface is
the console. You'd use something like this:

print("value value data data data", end="\r")

That'll print out whatever you want, and then move the cursor to the
beginning of the line, so the next output will be on the same line.
This is the technique I use in LetMeKnow [1] to create a spinning
display; when the event changes, it writes a newline (and thus
advances to the next line of output), but otherwise, it overwrites
each line with the next.

Other good user interfaces include web browsers (build your app in a
mix of Python and HTML, so a button click sends a request to a server)
and classic GUIs (Python includes one GUI library by default, and you
can pick up others from PyPI). But I'd recommend giving the end="\r"
technique a try first; based on your "without scrolling" comment, I'm
guessing you've already tried the console and found it almost, but not
quite, what you want, so this would be a very small change.

Hope that helps! Happy to clarify further if you have questions.

ChrisA

[1] https://github.com/Rosuav/LetMeKnow/blob/master/letmeknow.py#L175



More information about the Python-list mailing list