from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
from sqlhandling import Sql
from text import Text
import random
picture = Image.new("RGB", (1500, 1500), "Cyan")
Sql.openDataBase('TothBalint', 'postgres', 'localhost', 'pw')
Sql.writeQuery(''' SELECT name, budget_value, budget_currency, main_color FROM project
WHERE project IS NOT NULL;''')
first_tuple_list = Sql.getData()
fonttype_list = ["Fonts/Capture_it.ttf", "Fonts/OpenSans-Bold.ttf", "Fonts/AlexBrush-Regular.ttf",
                 "Fonts/Capture_it_2.ttf", "Fonts/FFF_Tusj.ttf", "Fonts/Pacifico.ttf", "Fonts/SEASRN__.ttf"]

# Formatting the SQL data so the text object can be created
first_list = [list(tuple) for tuple in first_tuple_list]

# Changing the currency to EUR
for project in first_list:
    if project[2] == "USD":
        project[1] = int(float(project[1]) * 0.9)
    elif project[2] == "GBP":
        project[1] = int(float(project[1]) * 1.17)
    else:
        project[1] = int(float(project[1]))
    project[2] = "EUR"

# Getting rid of the "#" symbol and making a list from the color string
    project[3] = list(project[3].replace("#", ""))