profile
Размещено 1 год назад по предмету Информатика от vladkrivko2020

Добавьте менюшку для програмы , где будет название ("TurtleDraw") , кнопка с надписью Start и Exit

from turtle import *

screen = Screen()
screenMinX = -screen.window_width()/2
screenMinY = -screen.window_height()/2
screenMaxX = screen.window_width()/2
screenMaxY = screen.window_height()/2

screen.setworldcoordinates(screenMinX,screenMinY,screenMaxX,screenMaxY)

brush_turtle = Turtle()
brush_turtle.goto(0, 0)
brush_turtle.speed(10)

def on_screen_click(x, y):
if y < screenMaxY - 40: # only draw if clicked below color squares
brush_turtle.goto(x, y)

screen.onclick(on_screen_click)

class ColorPicker(Turtle):
def __init__(self, color="red",num=0):
Turtle.__init__(self)
self.num = num
self.color_name = color
self.speed(0)
self.shape("circle")
self.color("black", color)
self.penup()

self.onclick(lambda x, y: self.handle_click(x, y))

def draw(self):
self.setx(screenMinX+110+self.num*30)
self.sety(screenMaxY - 20)

def handle_click(self, x, y):
if self.color_name == "#F9F9F9":
brush_turtle.penup()
brush_turtle.color("black")
else:
brush_turtle.pendown()
brush_turtle.color(self.color_name)

screen.tracer(0)

ui_turtle = Turtle()
ui_turtle.ht()
ui_turtle.penup()
ui_turtle.goto(screenMinX, screenMaxY - 23)
ui_turtle.write("TurtleDraw!", align="left", font=("Courier", 10, "bold"))

colors = ["red", "orange", "yellow", "green", "blue", "indigo", "violet", "black", "#F9F9F9"]
color_pickers = [ColorPicker(color=c, num=i) for i, c in enumerate(colors)]
for picker in color_pickers:
picker.draw()
screen.tracer(1)

  1. Ответ на вопрос
    Ответ на вопрос дан neverloseee

    Відповідь:

    from turtle import *

    screen = Screen()

    screenMinX = -screen.window_width() / 2

    screenMinY = -screen.window_height() / 2

    screenMaxX = screen.window_width() / 2

    screenMaxY = screen.window_height() / 2

    screen.setworldcoordinates(screenMinX, screenMinY, screenMaxX, screenMaxY)

    brush_turtle = Turtle()

    brush_turtle.goto(0, 0)

    brush_turtle.speed(10)

    def on_screen_click(x, y):

       if y < screenMaxY - 40:  # only draw if clicked below color squares

           brush_turtle.goto(x, y)

    def start():

       screen.onclick(on_screen_click)

    def exit():

       screen.bye()

    class ColorPicker(Turtle):

       def __init__(self, color="red", num=0):

           Turtle.__init__(self)

           self.num = num

           self.color_name = color

           self.speed(0)

           self.shape("circle")

           self.color("black", color)

           self.penup()

           self.onclick(lambda x, y: self.handle_click(x, y))

       def draw(self):

           self.setx(screenMinX + 110 + self.num * 30)

           self.sety(screenMaxY - 20)

       def handle_click(self, x, y):

           if self.color_name == "#F9F9F9":

               brush_turtle.penup()

               brush_turtle.color("black")

           else:

               brush_turtle.pendown()

               brush_turtle.color(self.color_name)

    screen.tracer(0)

    ui_turtle = Turtle()

    ui_turtle.ht()

    ui_turtle.penup()

    ui_turtle.goto(screenMinX, screenMaxY - 23)

    ui_turtle.write("TurtleDraw!", align="left", font=("Courier", 10, "bold"))

    colors = ["red", "orange", "yellow", "green", "blue", "indigo", "violet", "black", "#F9F9F9"]

    color_pickers = [ColorPicker(color=c, num=i) for i, c in enumerate(colors)]

    for picker in color_pickers:

       picker.draw()

    screen.tracer(1)

    # Adding menu

    menu = Screen()

    menu.setup(width=200, height=200)

    menu.title("TurtleDraw")

    menu.addshape("button.gif")  # assuming you have an image for the button

    menu.addshape("exit_button.gif")  # assuming you have an image for the exit button

    menu.register_shape("button.gif", ((0, 0), (0, 30), (60, 30), (60, 0), (0, 0)))

    menu.register_shape("exit_button.gif", ((0, 0), (0, 30), (80, 30), (80, 0), (0, 0)))

    start_button = Turtle("button.gif")

    start_button.speed(0)

    start_button.penup()

    start_button.goto(-80, 40)

    start_button.write("Start", align="left", font=("Courier", 12, "normal"))

    start_button.showturtle()

    start_button.onclick(start)

    exit_button = Turtle("exit_button.gif")

    exit_button.speed(0)

    exit_button.penup()

    exit_button.goto(-80, 0)

    exit_button.write("Exit", align="left", font=("Courier", 12, "normal"))

    exit_button.showturtle()

    exit_button.onclick(exit)

    menu.mainloop()

    Пояснення:

Не тот ответ на вопрос, который вам нужен?
Найди верный ответ
Самые новые вопросы
tegysigalpa2012
Русский язык - 6 лет назад

Помогите решить тест по русскому языку тест по русскому языку «местоимение. разряды местоимений» для 6 класса 1. укажите личное местоимение: 1) некто 2) вас 3) ни с кем 4) собой 2. укажите относительное местоимение: 1) кто-либо 2) некоторый 3) кто 4) нам 3. укажите вопросительное местоимение: 1) кем-нибудь 2) кем 3) себе 4) никакой 4. укажите определительное местоимение: 1) наш 2) который 3) некий 4) каждый 5. укажите возвратное местоимение: 1) свой 2) чей 3) сам 4) себя 6. найдите указательное местоимение: 1) твой 2) какой 3) тот 4) их 7. найдите притяжательное местоимение: 1) самый 2) моего 3) иной 4) ничей 8. укажите неопределённое местоимение: 1) весь 2) какой-нибудь 3) любой 4) этот 9. укажите вопросительное местоимение: 1) сколько 2) кое-что 3) она 4) нами 10. в каком варианте ответа выделенное слово является притяжательным местоимением? 1) увидел их 2) её нет дома 3) её тетрадь 4) их не спросили

Информация

Посетители, находящиеся в группе Гости, не могут оставлять комментарии к данной публикации.