Entering Text

Entries

Sometimes buttons are not enough.  You want the user to enter information like their name or a number.  In that case GUI4sher uses the entry widget.  The place_entry function puts a rectangle that the user can type in.  Place_entry requires an integer argument that is how many characters wide the rectangle is.  So if the user writes place_entry(7) it will place a rectangle with room for 7 characters.  The user can type more characters but only 7 will be visible. 

Text

Description automatically generated with medium confidence

Its good to label your entry so the user can tell what to enter in the entry.

Graphical user interface, text

Description automatically generated

In the clicks file you can edit the function with the entry name followed by _return.  This function will happen when the user hits the enter (sometimes called return) key when typing the entry.

You can use the get_text method to get what the user typed.  You can also use other methods mentioned previously like set_fill, get_fill, set_font, get_font and so on.  In the example below the name_entry_return function was set up to say hello to the user when he enters his name and hits hello.

Graphical user interface, application

Description automatically generated

Graphical user interface, text

Description automatically generated

Text

The text widget allows the user to enter or view multiline text.  You add a text widget with the place_text function.  The function has 2 arguments for the number of characters in a line and the number of lines.  There is no function in the click file for that, if you want to respond to the text the user enters you need to add a button.  You can do things with the text using the get_text method.  The example below finds if the users name is in the text.

Graphical user interface, application

Description automatically generated

Graphical user interface, text, application

Description automatically generated

The first few times I wrote this I used elif index = len(name) -1  instead of elif index == len(name) – 1

You can se that GUI4sher reported this error and the line it occurred on.

Graphical user interface

Description automatically generated

Graphical user interface, text, application

Description automatically generated

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

                                                                                                                                                  /

Another error was reported since name_text was used instead of words_text.  All such errors are reported in red.  Once that error was corrected the project could find names and not find names in it.

Creating an App

Once you created a complex project you might want to share it with friends or submit it as an assignment.  You can use the Make App button (green button on the right side) to create a python app.

The first thing that happens when you click make app is that it requests a name and location for the app file.

A screenshot of a computer

Description automatically generated

The app has no shell but it does the same thing as the GUI4sher project:

Graphical user interface, text, application

Description automatically generated

Graphical user interface, text, application

Description automatically generated

Graphical user interface, text, application

Description automatically generated

Click here to see how a lists work in GUI4sher

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]