Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 134 - 2615_KEC
P. 134

    3.   Start typing your Python code in the CodeSkulptor3 editor. The platform automatically includes

                         the SimpleGUI library, so you don’t need to install anything extra.
                      4.   Click the Run button in CodeSkulptor3 to see the output. The graphics and animations you
                         create will appear in a window within the platform.

                                UNDERSTANDING COORDINATES

                      Before you start drawing anything on the canvas in SimpleGUI, it’s important to understand how
                      coordinates work. In SimpleGUI, you use a coordinate system to define where you want to draw

                      shapes, lines or text. This system is based on pixels, which are the tiny dots that make up the
                      screen.
                      Let us understand how the coordinate system works:

                          The origin is at the top-left corner of the screen, represented as (0, 0).

                          The x-value increases as you move to the right.
                          The y-value increases as you move down the screen.

                                WOKING ON SIMPLEGUI CANVAS

                      In SimpleGUI, you can draw shapes, lines and even add text to your program. The canvas is the

                      area where everything is drawn and you can interact with it using coordinates. Let's start by
                      learning how to create a simple drawing using SimpleGUI.

                      DRAWING A LINE
                      Drawing a line means connecting two points on the canvas using a straight path. You can control
                      the starting and ending positions of the line, its thickness and its colour. Here is the syntax to draw
                      a line:

                                       canvas.draw_line(point1, point2, width, color)

                      132   Premium Edition-VII

| 129 130 131 132 133 134 135 136 137 138 139 |