Buttons: Simple User Input

Simple Button

The place_button function can put a button on a GUI4sher project.  Place_button requires a string argument which is written on the button.  So if you want a button labelled orange you would write place_button(‘orange’).

Text

Description automatically generated

Of course clicking on the button doesn’t do anything, because the computer does not know what you intend.  To make the button do something use the green Edit Clicks button on the right side of the screen.

A picture containing waterfall chart

Description automatically generated

When you click that button you get a clicks file editor.  def orange_button_click():  is used to define what happens when the orange button is clicked.  Currently it does pass which means do nothing.  But pass can be edited to a different action.

Graphical user interface

Description automatically generated with medium confidence

Now this should change the behavior for clicking the button. Now when the button is clicked this is the result.

Waterfall chart

Description automatically generated

Counting Button

A more complex button counts how many times it was clicked. We start by creating counter_button whose label shows how many clicks happen.  It starts with ‘Not clicked’.

Waterfall chart

Description automatically generated

Chart, waterfall chart

Description automatically generatedChart, waterfall chart

Description automatically generated

The clicks file defines a count variable and has the count variable increase every time you click.  It will show the value of the count variable on the button.

Chart, waterfall chart

Description automatically generated

Chart, waterfall chart

Description automatically generated

Check

Sometimes one wants to show if the user clicked and allow him if it is a mistake to undo the click.  The widget called check does this.  It is like a button except it has a visual check on the screen.  It has a method called get_check that returns True or False (Boolean values) depending whether it is  checked.  It also has a method called set_check that allows you to set the check to True or False (and shows it visually).

Graphical user interface, text

Description automatically generated 

You can control what happens when you click on the check the same way as you control what buttons do:

Graphical user interface, text, application

Description automatically generated

This is what it looks like when you click on the check:

Graphical user interface, text

Description automatically generated

Click to see widgets that allow the user to enter words.

Contents

·      GUI4sher How To

o   Downloading

o   Starting a new project

·      The Structure of a GUI4sher project

·      Adding Geometric Objects to a GUI4sher Project

o   Geometric Object

o   Rectangles

o   Modifying Colors and Borders

·      Ovals and Lines[SD1] 

o   Ovals

o   Lines

o   Polygons

·      Labels: Putting Words on GUI4sher

·      Buttons: Simple User Input

o   Simple Button

o   Counting Button

o   Check

·      Entering Text

o   Entries

o   Text

o   Creating an App

·      Lists in GUI4sher

o   List for Selecting a String

o   Editable List of Numbers

·       Project Administration

o   Copyright and Thanks

o   Debugging

 


 [SD1]