Example #1
0
class Frame:
    def __init__(self, width, height, bgColor, title):
        self.frame = Canvas(width, height, bgColor, title)
        # constructs a new Frame object

    def getWidth(self):
        return self.frame.getWidth()
        # returns the width of the Frame

    def getHeight(self):
        return self.frame.getHeight()
        # returns the height of the Frame

    def setWidth(self, width):
        self.frame.setWidth(width)
        # sets a new width for the Frame

    def setHeight(self, height):
        self.frame.setHeight(height)
        # sets a new height for the Frame

    def add(self, obj):
        self.frame.add(obj)
        # adds a new object to the Frame

    def getContents(self):
        return self.frame.getContents()

    def close(self):
        self.frame.close()

    def wait(self):
        self.frame.wait()

    def remove(self, obj):
        self.frame.remove(obj)

    def setTitle(self, title):
        self.frame.setTitle(title)
#-*- encoding: utf-8 -*-
from cs1graphics import Canvas, Layer, Rectangle, Image, Text, Circle, Point
import os
import sys
import random as rd
from time import sleep

paper = Canvas()
paper.setWidth(1000)  # 가로
paper.setHeight(600)  # 세로
paper.setBackgroundColor("skyblue")

console_clear = "cls" if os.name == "nt" else "clear"


def execute():
    global paper
    paper.clear()
    os.system(console_clear)
    #####################################################
    Main = Layer()
    start = Rectangle(200, 100, Point(275, 450))
    start.setFillColor('yellow')
    Main.add(start)
    way = Rectangle(200, 100, Point(525, 450))
    way.setFillColor('yellow')
    Main.add(way)
    paper.add(Main)

    Man = Layer()
    man = Image("python/man.png")