Adding Geometric Objects to a GUI4sher Project

Geometric Object

GUI4sher knows about these geometric object:

·        circle

·        rectangle

·        oval

·        line

·        dashed_line

·        polygon

You add them to a GUI4sher project by using a place function.

For example in this figure:

The place_circle function placed a circle called red_circle in the graphics window.  You don’t need the parameters above.  If you just type place_circle() it will ask you for the name of your circle.  You need the name so you can modify or delete the circle later.  The name must be a valid python variable name so it can not have spaces and requires alpha-numeric characters or ‘_’ and can not start with a number or match a python keyword like ‘if’.  Below is a simple place_circle function call:

Text

Description automatically generated

Once enter is typed it then asks for the position of the center of the circle and a point on its edge:

A picture containing circle

Description automatically generated

The functions to put geometric objects in the graphics window are:

·        place_circle()

·        place_rectangle()

·        place_oval()

·        place_line()

·        place_dashed_line()

·        place_polygon()

Rectangles

You place rectangles in the graphics area of a GUI4sher project by clicking on two opposite corners.  Once you name your rectangle it asks you to click on the first corner. Guide lines appear when it asks you to click so that you can line up GUI4sher objects.  In the figure below the guidelines are for placing the rectangle around the circle.

Graphical user interface

Description automatically generated

Then you it asks you to click on the diagonal corner it It leaves a dot to show you where the first corner was.  The dot will disappear when you create the rectangle with the second click.

A picture containing shape

Description automatically generated

This time the name of the rectangle was put in the ()’s in quotes. 

Modifying Colors and Borders

You can modify the width of the border with the set_width method.  You use the name of the object followed by a period followed by the word set_width.

A call to set_width looks like this:

demo_rectangle.set_width(5)

This tells GUI4sher to make the border 5 pixels wide.

Shape

Description automatically generated

You can change the color of the border by using the set_outline method.  You don’t need quotes for common colors like red.

Graphical user interface, application

Description automatically generated

If you want a more exotic color like spring green you will need to quote it.

Graphical user interface, application

Description automatically generated

The predefined colors are:

·        red = 'red'

·        green = 'green'

·        blue = 'blue'

·        white = 'white'

·        black = 'black'

·        gray = 'gray'

·        orange = 'orange'

·        purple = 'purple'

·        violet = 'violet'

·        yellow = 'yellow'

·        brown = 'brown'

·        cyan = 'cyan'

·        magenta = 'magenta'

·        pink = 'pink'

You can change the color of the inside of an object by using the set_fill method as show below:

Graphical user interface, application

Description automatically generated

Click here to see how to put more objects like ovals and lines into a GUI4sher project

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]