#!/usr/bin/python3

import pygame
from display_text import Display_Activity 

class Network_Traffic:
    def __init__(self):
        pygame.init()

        self.i_need_this_to_prevent_errors = True

        self.clock = pygame.time.Clock()

        self.screen = pygame.display.set_mode((600, 370))
        self.screen_rect = self.screen.get_rect()
        pygame.display.set_caption('Network traffic (lesbians, edition)')

        self.screen_color = (0, 0, 0)

        self.display_activity = Display_Activity(self)

        self.lesbians = pygame.image.load('uranus/uranus2.png')
        self.lesbians_rect = self.lesbians.get_rect()
        self.lesbians_rect.midbottom = self.screen_rect.midbottom

    def check_events(self):
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                self.i_need_this_to_prevent_errors = False
            elif event.type == pygame.KEYDOWN:
                if event.key == pygame.K_q:
                    self.i_need_this_to_prevent_errors = False

    def update_screen(self):
        self.screen.fill(self.screen_color)
        self.screen.blit(self.lesbians, self.lesbians_rect)
        self.display_activity.show_text()
        pygame.display.flip()

    def run_network(self):
        while self.i_need_this_to_prevent_errors == True:
            self.check_events()
            self.update_screen()
            self.clock.tick(3)
        pygame.quit()

