Page 113 - KEC Khaitan C7 Flipbook
P. 113

PROJECT NAME 8: Creating a Scene (Independence Day/Christmas) Using SimpleGUI
                 Software Used: CodeSkulptor

                 Objective:

                 Use SimpleGUI in CodeSkulptor3 (Codeskulptor3.-https://py3.codeskulptor.org/) to draw shapes
                 and design a visual scene representing Independence Day, Christmas, or any themed event.

                 Use Codeskulptor3-https://py3.codeskulptor.org/
                 Step-by-Step Instructions: (Plan IPO)
                 1.  Input:

                         Plan the objects/entities you want to display on the canvas (e.g., flag, star, snowman, tree).
                         Identify the basic shapes (lines, circles, polygons) that make up each object.

                 2.  Process: Use SimpleGUI drawing functions to create your scene:
                         canvas.draw_line – Draws a straight line between two points (e.g., flagpole or ground
                         line).

                         canvas.draw_polygon  – Creates  a  closed  shape  by  connecting  multiple  points  (e.g.,
                         flags, stars).

                         canvas.draw_circle –  Draws  a circle with a specified  center and radius  (e.g., sun,
                         ornaments, or balloons).

                         canvas.draw_arc – Draws a curved line or arc (e.g., rainbow, semi-circles).
                 3.  Sample Code:

                     import simplegui
                     message = "Welcome!"

                     message2 = "ABC XYZ 7C"
                     # Handler to draw on canvas

                     def draw(canvas):
                         canvas.draw_text(message, [50,112], 48, "yellow")

                         canvas.draw_line([120,100],[12,100],5,"red")

                         canvas.draw_circle([60,30],20,8,"white","green")
                         canvas.draw_text(message2, [240,195], 10, "yellow")

                     # Create a frame and assign callbacks to event handlers

                     frame = simplegui.create_frame("Home", 300, 200)
                 4.  Output:

                         Display a scene featuring a flag, emoji, holiday decoration, or themed structure.

                         The output may show a flagpole, sun, and decorative elements arranged according to the
                         event theme.




                                                                                        Control Structures in Python  111
   108   109   110   111   112   113   114   115   116   117   118