Форум программистов, компьютерный форум, киберфорум
Python: PyGame
Войти
Регистрация
Восстановить пароль
Карта форума Темы раздела Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.89/55: Рейтинг темы: голосов - 55, средняя оценка - 4.89
26 / 26 / 0
Регистрация: 31.01.2020
Сообщений: 182
1

Я слежу за тобой!

30.12.2020, 11:30. Показов 11269. Ответов 10
Метки нет (Все метки)

Author24 — интернет-сервис помощи студентам
Напишите программу, которая средствами Pygame создает окно размером 200×200 пикселей.

Пользователь должен иметь возможность сворачивать и разворачивать это окно.

Программа должна выводить строго по центру окна стандартным шрифтом красного цвета размером 100 пикселей сколько раз окно было свернуто.

Считайте, что при запуске программы окно появляется в первый раз.
Миниатюры
Я слежу за тобой!  
0
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
30.12.2020, 11:30
Ответы с готовыми решениями:

Хочу создать бота который общается с тобой
Всем привет,заинтересовался недавно идеей создать бота который будет отвечать определенным образом...

Хочу создать бота который общается с тобой
Всем привет,заинтересовался идеей создания чат бота который мог бы отвечать на вопросы пользователя...

Как понять закрепиться за тобой реферал или нет
Здравствуйте. Интересует такой вопрос: Реферальные ссылки должны привязываться к браузерной...

Создать список обьектов созданного тобой класса на основе задачи (представлена ниже)
1. Создать список обьектов созданного тобой класса на основе задачи. 2. Добавить в список 4-5...

10
26 / 26 / 0
Регистрация: 31.01.2020
Сообщений: 182
26.02.2021, 17:56  [ТС] 2
помогите
0
0 / 0 / 0
Регистрация: 15.03.2021
Сообщений: 4
21.01.2023, 18:23 3
Прости если поздно, недавно сам только разобрался
Python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import pygame
count = 1
pygame.font.init()
f1 = pygame.font.Font(None, 50)
text = f1.render(str(count), True, (255, 0, 0))
 
if __name__ == '__main__':
    pygame.init()
    pygame.display.set_caption('Я слежу за тобой!')
    size = width, height = 200, 200
    screen = pygame.display.set_mode(size)
    running = True
    count = 1
    red = (255, 0, 0)
    while running:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                running = False
            if event.type == pygame.WINDOWHIDDEN:
                count += 1
            if event.type == pygame.WINDOWSHOWN:
                text = f1.render(str(count), True, red)
                screen.blit(text, (90, 90))
                pygame.display.update()
                pygame.display.flip()
        screen.fill((0, 0, 0))
    pygame.quit()
0
Йуный плагиат-падаван)
133 / 118 / 45
Регистрация: 17.10.2022
Сообщений: 565
21.01.2023, 20:14 4
Python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import pygame
 
# Initialize pygame and create a window
pygame.init()
window = pygame.display.set_mode((200, 200))
pygame.display.set_caption("Window")
 
# Create a font and a text surface to display the number of times the window was minimized
font = pygame.font.Font(None, 100)
text_surface = font.render("0", True, (255, 0, 0))
 
# Create a variable to keep track of the number of times the window was minimized
minimized_count = 0
 
# Main loop
running = True
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
        elif event.type == pygame.ACTIVEEVENT:
            if event.state == pygame.APPACTIVE and event.gain == 0:
                minimized_count += 1
                text_surface = font.render(str(minimized_count), True, (255, 0, 0))
 
    # Clear the screen
    window.fill((0, 0, 0))
 
    # Blit the text surface to the center of the screen
    window.blit(text_surface, (50, 50))
 
    # Update the display
    pygame.display.update()
 
# Quit pygame
pygame.quit()
Добавлено через 52 секунды
NorthCrowler, цыфра цифра у вас масипусенькая
0
171 / 104 / 25
Регистрация: 17.10.2010
Сообщений: 1,146
22.01.2023, 14:22 5
Цитата Сообщение от DOPIXKMNLD Посмотреть сообщение
Python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import pygame
# Initialize pygame and create a window
pygame.init()
window = pygame.display.set_mode((200, 200))
pygame.display.set_caption("Window")
# Create a font and a text surface to display the number of times the window was minimized
font = pygame.font.Font(None, 100)
text_surface = font.render("0", True, (255, 0, 0))
# Create a variable to keep track of the number of times the window was minimized
minimized_count = 0
# Main loop
running = True
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
        elif event.type == pygame.ACTIVEEVENT:
            if event.state == pygame.APPACTIVE and event.gain == 0:
                minimized_count += 1
                text_surface = font.render(str(minimized_count), True, (255, 0, 0))
# Clear the screen
    window.fill((0, 0, 0))
# Blit the text surface to the center of the screen
    window.blit(text_surface, (50, 50))
# Update the display
    pygame.display.update()
# Quit pygame
pygame.quit()
В чем ошибка????
Traceback (most recent call last):
File "Z:/Python/p1696/Lib/site-packages/Drawing window.py", line 26, in <module>
if event.state == pygame.APPACTIVE and event.gain == 0:
AttributeError: 'Event' object has no attribute 'state'

Добавлено через 41 секунду
Как исправить????
0
-109 / 6 / 1
Регистрация: 22.01.2023
Сообщений: 8
22.01.2023, 14:59 6
Python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import pygame
 
# Initialize pygame
pygame.init()
 
# Set the window size
size = (200, 200)
 
# Create the window
screen = pygame.display.set_mode(size)
 
# Set the window title
pygame.display.set_caption("Minimize Counter")
 
# Initialize the minimize counter
minimize_counter = 0
 
# Set the font and font size
font = pygame.font.Font(None, 100)
 
# Run the game loop
running = True
while running:
    for event in pygame.event.get():
        # Handle the QUIT event
        if event.type == pygame.QUIT:
            running = False
 
        # Handle the WINDOWEVENT event
        if event.type == pygame.WINDOWEVENT:
            # Handle the WINDOWEVENT_MINIMIZED event
            if event.event == pygame.WINDOWEVENT_MINIMIZED:
                minimize_counter += 1
 
    # Clear the screen
    screen.fill((0, 0, 0))
 
    # Render the minimize counter text
    text = font.render(str(minimize_counter), True, (255, 0, 0))
 
    # Get the size of the text
    text_rect = text.get_rect()
 
    # Position the text in the center of the screen
    text_rect.center = (size[0] // 2, size[1] // 2)
 
    # Draw the text on the screen
    screen.blit(text, text_rect)
 
    # Update the display
0
Йуный плагиат-падаван)
133 / 118 / 45
Регистрация: 17.10.2022
Сообщений: 565
22.01.2023, 17:04 7
isaak, по догадкам:
Вместо:
Python
1
if event.state == pygame.APPACTIVE and event.gain == 0:
Нужно использовать:
Python
1
if event.type == pygame.ACTIVEEVENT and event.state == pygame.APPACTIVE and event.gain == 0:
Добавлено через 1 минуту
или махнуть

Python
1
elif event.type == pygame.ACTIVEEVENT:
на

Python
1
elif event.type == pygame.VIDEORESIZE:
плюс возможно на это:

Python
1
elif event.type == pygame.ACTIVEEVENT and event.gain == 0
0
171 / 104 / 25
Регистрация: 17.10.2010
Сообщений: 1,146
22.01.2023, 21:04 8
DOPIXKMNLD,
Python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import pygame
# Initialize pygame and create a window
pygame.init()
window = pygame.display.set_mode((200, 200))
pygame.display.set_caption("Window")
# Create a font and a text surface to display the number of times the window was minimized
font = pygame.font.Font(None, 100)
text_surface = font.render("0", True, (255, 0, 0))
# Create a variable to keep track of the number of times the window was minimized
minimized_count = 0
# Main loop
running = True
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
          elif event.type == pygame.ACTIVEEVENT and event.gain == 0
           if event.type == pygame.ACTIVEEVENT and event.state == pygame.APPACTIVE and event.gain == 0:
                minimized_count += 1
                text_surface = font.render(str(minimized_count), True, (255, 0, 0))
# Clear the screen
    window.fill((0, 0, 0))
# Blit the text surface to the center of the screen
    window.blit(text_surface, (50, 50))
# Update the display
    pygame.display.update()
# Quit pygame
pygame.quit()
Теперь вот такую ошибку выдает????
C:\Users\Администратор\AppData\Local\Programs\Python\Python38\pythonw.exe "Z:/Python/p1698/Lib/site-packages/Drawing window.py"
File "Z:/Python/p1698/Lib/site-packages/Drawing window.py", line 17
elif event.type == pygame.ACTIVEEVENT and event.gain == 0
^
IndentationError: unindent does not match any outer indentation level
0
4921 / 2674 / 550
Регистрация: 07.11.2019
Сообщений: 4,395
23.01.2023, 06:46 9
isaak, ясно же написано, что дело в отступах. У вас elif не находится на том же уровне что и if
0
0 / 0 / 0
Регистрация: 15.03.2021
Сообщений: 4
23.01.2023, 14:21 10
А почему не используете WINDOWHIDDEN? Просто я в Pygame недавно, может быть я что-то нет понимаю?
0
5 / 4 / 1
Регистрация: 07.01.2023
Сообщений: 13
04.12.2023, 15:07 11
Python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import pygame
 
if __name__ == '__main__':
    pygame.init()
    pygame.display.set_caption('Перетаскивание')
    size = width, height = 200, 200
    screen = pygame.display.set_mode(size)
    f1 = pygame.font.Font(None, 100)
    running = True
    text_color = (255, 0, 0)
    counter = 0
    while running:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                running = False
            elif event.type == pygame.ACTIVEEVENT:
                if event.state == pygame.APPACTIVE and event.gain == 0:
                    counter += 1
                    text_surface = f1.render(str(counter), True, (255, 0, 0))
 
        screen.fill((0, 0, 0))
        text = f1.render(str(counter), True, text_color)
        text_rect = text.get_rect(center=(width // 2, height // 2))  # Размещаем текст по центру окна
        screen.blit(text, text_rect)
        pygame.display.flip()
 
    pygame.quit()
0
04.12.2023, 15:07
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
04.12.2023, 15:07
Помогаю со студенческими работами здесь

Перед тобой программа, в которой описан класс «Круг» и определён метод circumference()
Приветствую помогите пожалуйста кто шарит не знаю как исправить. Программа запрашивает у...

Нужно слово или корень слов в иностранных языках, означающее прямую между тобой и целью
нужно слово или корень слов в язках английский-французкий-испанский и германский означающее прямую...

[Био/Зоология] Есть ли какой-нибудь ресурс, чтобы узнать, как называется увиденная тобой особь?
Например, я увидел лягушку или улитку, хочу узнать по описанию как она называется, куда я могу...

Как сделать так, чтобы нельзя было встать из приседа если над тобой находится объект (коллайдер)?
Сделал функцию приседания на LeftShift - два скрипта C#, один опускает камеру ( от первого лица ),...

Написать программу прохождения теста "Интересно ли с тобой общаться"
Написать программу прохождения теста пользователем. ТЕСТ: ИНТЕРЕСНО ЛИ С ТОБОЙ ОБЩАТЬСЯ? Если ты...

Показать кто за тобой, а кто до тебя
Добрый день форумчане хочу вывести топ аккаунтов с наибольшее кол-во сообщений (топ 15 аккаунтов)...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
11
Ответ Создать тему
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2024, CyberForum.ru