Want to keep learning?

This content is taken from the Raspberry Pi Foundation & National Centre for Computing Education's online course, Programming with GUIs. Join the course to learn more.
1.3

What is a GUI and why do we have them?

The earliest computers had no keyboards or monitors, and would instead use punchcards for input and line printers to provide output. When monitors were introduced, these generally used text-based output in response to commands entered by the user.

As the potential for computers became increasingly apparent, the first graphical user interfaces (usually abbreviated to GUIs) were introduced in the early 1970s to try and mitigate the steep learning curve of command-line interfaces. This Wikipedia article gives a history of the GUI.

Different uses make for different requirements for user interfaces:

• Home users commonly use operating systems such as Windows 10, as these ‘feel’ familiar and intuitive. This consistency means that one computer works much the same as the next.
• Tablets and smartphones rely on software-based keyboards as well as controls based on gestures (e.g. swiping a finger to scroll) or finger taps, alongside more traditional form-based interfaces.
• The most powerful computers on the planet tend to run Linux-based operating systems and are typically accessed via a command line because of the flexibility this affords more experienced computer scientists.

You’ll come across a few interface terms throughout this course; some are listed here for your convenience.

Term Definition
User interface Hardware or software to allow users to interact with their computers.
Graphical user interface (GUI) A software interface based around visual elements such as buttons and text boxes.
Form-based GUI A GUI that is similar to a paper-based form, e.g. a sign-up page for a social media platform.
WIMP Acronym for ‘windows, icons, menus, pointers’. Typically used as a shorthand way to describe traditional GUI elements.
Command-line interface (CLI) A software interface whereby users type in commands at a prompt to accomplish tasks, such as the Linux terminal.

GUI vs CLI

Both GUIs (Raspbian, Windows, MacOS) and text-based CLIs (Windows command prompt/PowerShell, the Linux terminal) have their own strengths and weaknesses that are generally complementary.

• Experienced users can perform flexible, powerful custom commands in CLI envionments to complete useful work and can chain commands together. GUI environments tend to require users to complete one task at a time.
• CLIs generally allow experienced users to work faster than a GUI, but inexperienced users will find a GUI easier to start with.
• A CLI will require fewer system resources such as hard disk space, RAM, CPU and GPU time to render its interface than the equivalent GUI.
• Good GUIs can often be used intuitively, and commonly have built-in help readily available, while CLIs require training for users to understand the commands.
• Users will generally need to memorise CLI commands, while GUIs often provide hints as to what elements do through careful use of icons and labels.

Some workflows lend themselves better to CLIs and others to GUIs. Imagine we wanted to move a file:

In a GUI environment you could accomplish this in a few different ways. One way would be to click-and-drag the file from its current location to a new one. The CLI version would probably be slower; for example, on Linux you’d type something like:

cd folderName
mv file.jpg ../newFolder


Let’s try something else: what if we had 1000 files in that directory and we only wanted to move the ones that ended with ‘.jpg’? In our GUI system, you’d probably need to browse to the folder, right-click, sort by type, scroll to where the JPG files were, click on the first one in the list, scroll a bit, hold shift, click on the last one in the list, then drag and drop them into the new directory. On a Linux machine, you’d type:

cd folderName
mv *.jpg ../newFolder/


What about ordering a pizza?

On my phone, I would load their website, pick out toppings from beautiful visualisations by tapping and scrolling, tap ‘pay’, and my meal would arrive a short time later — much easier than navigating through a text-based browser using the arrow keys! The take-away message at this point is that some jobs are better done with a GUI and some with a CLI. In the coming pages, we’ll look at how to create some GUIs using the guizero library.

Challenges

1. For each of these applications, state whether you feel a GUI or a CLI would be better, justifying your answer.

• A desktop publishing application
• A photo sharing application
• Programs to performing complex file operations on a large system
• A web browser for a visually impaired user
2. Identify another specific situation where a command line would be better and one where a GUI would be better.