Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 138 - 2615_KEC
P. 138

    10
                        11   # Set the draw handler (tells SimpleGUI to use the draw function to display content)
                        12   frame.set_draw_handler(draw)
                        13
                        14   # Start the frame to display the canvas
                        15   frame.start()
                        16

                       Output

                                              Triangle                   Expand     Hide    Close

                                               Key:
                                               Mouse:

                      TYPING TEXT

                      You can also add text to the canvas in SimpleGUI. This allows you to display words or messages

                      in your program, which can be useful for instructions, titles or any other information. Here is the
                      syntax to draw a line:

                      canvas.draw_text(text, position, font_size, color)

                      Let us understand the syntax:

                         text: Words to display, this is the actual text you want to show on the canvas. It can be any
                        string of characters, like "Hello", "Welcome" or any other message.

                         Position: Where the text starts, this is the (x, y) coordinate where the text will begin on the
                        canvas. The text will be placed starting at this point.

                         font_size: Size of the letters, this defines how big or small the text will be. The larger the font size,

                        the bigger the letters will appear.

                         Color: Text colour, this is the colour of the text, which you can set to any colour you like, such
                        as "black", "green" or "red".

                      136   Premium Edition-VII

| 133 134 135 136 137 138 139 140 141 142 143 |