Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 140 - 2615_KEC
P. 140

    Here is the syntax to create a frame:

                      frame = simplegui.create_frame("Title", width, height)

                      frame.set_draw_handler(draw)
                      frame.start()

                      Let us understand the syntax:
                         create_frame("Title",  width,  height): This function creates the window (frame)
                        where all the drawings will appear.

                         set_draw_handler(draw): This tells SimpleGUI what to draw on the canvas inside the frame.

                         start(): This function starts the program and makes the window appear on the screen. It
                        also starts an event loop that keeps the window open and continuously updates it based on the
                        draw function.

                           REVISIT

                            A canvas in Python is a digital space, like a blank screen, where you can draw various shapes, lines, and even
                          write text using code.
                            A Character User Interface (CUI), sometimes known as Command Line Interface (CLI), is text-based.
                            A  Graphical  User Interface  (GUI) is  the  type  of interface  you  most  commonly  use  when interacting  with
                          computers or mobile devices
                            A canvas is like a blank screen or a drawing board. When you write drawing commands in Python, they
                          appear on this canvas.
                            The canvas uses a coordinate system to determine where the shapes should be drawn.
                            A library in Python is a collection of pre-written code that you can use in your own programs.
                            SimpleGUI is a Python library that allows you to easily create graphics, shapes, and animations.
                            CodeSkulptor3 is an online platform that allows you to write and run Python code directly in your web browser.
                            Drawing a line means connecting two points on the canvas using a straight path.
                            Drawing a circle involves specifying the centre (middle point), radius (distance from the centre to the edge),
                          width (thickness of the border), and color (colour of the border).
                            A polygon is a shape with multiple sides. In SimpleGUI, you can draw polygons using the draw_polygon()
                          function
                            You can also add text to the canvas and display words or messages in your program, which can be useful for
                          instructions, titles, or any other information.
                            The frame is the main window that holds your canvas where you can draw shapes, lines, and text. Without the
                          frame, there would be no visible window to show your work.

                      138   Premium Edition-VII

| 135 136 137 138 139 140 141 142 143 144 145 |