Quer melhorar seu vocabulário? Baixe este app gratuitamente!

Baixe Bilderraten para melhorar seu vocabulário

Talvez você já saiba que fiquei internado durante 3 meses. Durante este tempo, criei cerca de 50 aplicativos para estudar alemão. Durante os próximos meses, aprimorarei, criarei instaladores, para que as pessoas que não tenham muito conhecimento de computador possam usar, e publicarei todos GRATUITAMENTE!

O primeiro é Bilderraten com o qual você pode melhorar seu vocabulário, não somente em alemão, mas também em quaisquer idiomas que você estiver estudando!

Não é necessário saber Python! Só baixar, iniciar, estudar!

Você pode baixar o instalador para Windows aqui:

É muito simples usar! Mas se você precisa de qualquer ajuda, assista a este vídeo:

Mais informações no GitHub!

Também publiquei uma instrução em inglês:

https://github.com/hansalemaos/Bilderraten

Se você tiver conhecimentos em Python e quiser me ajudar a melhorar o app, entre em contato comigo!

Aqui está o código:

Bilderraten.py 

import pathlib
import requests
from maximize_console import *
import bs4
from requests.utils import quote
import re
from screen_ocr._winrt import WinRtBackend
from PIL import Image, ImageEnhance
from tkinter.filedialog import askopenfilename
from tkinter import Tk
from random import shuffle
import kthread
from time import time, sleep
from add_color_print_reg import *
import shutil

drucker = Farbprinter()
specialkeysde = [
    ["German special character:", "Use:"],
    ["ä", "a:"],
    ["ö", "o:"],
    ["ü", "u:"],
    ["Ä", "A:"],
    ["Ö", "O:"],
    ["Ü", "U:"],
    ["ß", "sz"],
]
specialkeyspt = [
    ["Portuguese special character:", "Use:"],
    ["á", "a'"],
    ["â", "a!"],
    ["ã", "[email protected]"],
    ["à", 'a"'],
    ["c!", "ç"],
    ["é", "e'"],
    ["ê", "e!"],
    ["í", "i'"],
    ["ó", "o'"],
    ["ô", "o!"],
    ["õ", "[email protected]"],
    ["ú", "u'"],
    ["Á", "A'"],
    ["Â", "A!"],
    ["Ã", "[email protected]"],
    ["À", 'A"'],
    ["C!", "Ç"],
    ["É", "E'"],
    ["Ê", "E!"],
    ["Í", "I'"],
    ["Ó", "O'"],
    ["Ô", "O!"],
    ["Õ", "[email protected]"],
    ["Ú", "U'"],
]
allespecialkeys = specialkeysde[1:] + specialkeyspt[1:]


def datei_auswaehlen(
    message="Please choose TXT file with vocabulary (one word each line)",
    debug=True,
    readfile=True,
):
    content = ""
    drucker.p.brightyellow.black.italic(message)

    Tk().withdraw()
    filetypes = [("text files", "*.txt")]
    datei = askopenfilename(title=message, filetypes=filetypes)
    pathlibpfad = pathlib.Path(datei)
    if debug is True:
        drucker.p.brightyellow.black.italic(pathlibpfad)

    if readfile is True:
        try:
            content = pathlibpfad.read_text(encoding="utf-8")
        except:
            content = pathlibpfad.read_bytes()
    return pathlibpfad, content


def vokabelliste_einlesen():
    pfad, woerter = datei_auswaehlen(
        message="Please choose TXT file with vocabulary (one word each line)",
        debug=True,
        readfile=True,
    )
    woerter = woerter.splitlines()
    woerter = [str(w).strip() for w in woerter]
    escapedwords = [[w, quote(w, safe="")] for w in woerter]
    escapedwords = [
        [
            w[0],
            w[1],
            f"https://www.google.com/search?q={w[1]}&tbm=isch&hl=en&tbs=itp:clipart",
        ]
        for w in escapedwords
    ]
    return escapedwords


def get_htmllinks_of_wort(escapedwords):
    if not os.path.exists("tempbilder"):
        os.makedirs("tempbilder")
    fertigebilder = []
    htmlcode = requests.get(escapedwords[-1])
    suppe = bs4.BeautifulSoup(htmlcode.text, "html.parser")
    allebilder = suppe.findAll("img")
    for endi, bi in enumerate(allebilder):
        try:
            fertigebilder.append(
                [
                    f"tempbilder/{str(endi).zfill(7)}.png",
                    re.findall(r'src="(https://[^"]+)"', str(bi))[0],
                ]
            )
        except:
            continue
    return fertigebilder.copy()


def bildspeichern(bildname):
    with open(bildname[0], "wb") as f:
        f.write(requests.get(bildname[1]).content)
    gespeichertebilder.append(bildname[0])


def textrausschmeissen(gespeichertebilder):
    bilderohnetext = []
    for gesp in gespeichertebilder:
        bildfuerocr = Image.open(gesp).convert("L")
        bildfuerocr = bildfuerocr.convert("RGBA")
        bildfuerocr = ImageEnhance.Contrast(bildfuerocr).enhance(2)
        ocrbild = ocrscanner.run_ocr(bildfuerocr)
        for alle in ocrbild.lines:
            woerter = alle.words
            if any(woerter):
                bilderohnetext.append(gesp)
    brauchebarebilder = list(set(gespeichertebilder).difference(set(bilderohnetext)))
    return brauchebarebilder


def bilderstellen(brauchebarebilder):
    xeinfuegen = 0
    yeinfuegen = 0
    imggross = Image.new("RGBA", size=(1000, 2000), color=(255, 255, 255, 255))
    for indi, brauchbild in enumerate(brauchebarebilder):
        if yeinfuegen > 2000:
            break
        if indi % 2 == 0:
            continue
        img1 = Image.open(brauchbild).convert("RGBA")
        bildgroesse = img1.size
        faktor = 499 / bildgroesse[0]
        img1 = img1.resize((499, int(bildgroesse[1] * faktor)))
        img1 = ImageEnhance.Contrast(img1).enhance(3)
        imggross.paste(img1, (xeinfuegen, yeinfuegen))
        xeinfuegen = 499 + xeinfuegen
        if xeinfuegen == 998:
            yeinfuegen = yeinfuegen + 499
            xeinfuegen = 0
    imggross.save("tempbilder/endbild.png")


def delete_old_images():
    for bild in gespeichertebilder:
        os.remove(bild)
    os.remove("tempbilder/endbild.png")


def flattenlist(iterable):
    def iter_flatten(iterable):
        it = iter(iterable)
        for e in it:
            if isinstance(e, (list, tuple)):
                for f in iter_flatten(e):
                    yield f
            else:
                yield e

    a = [i for i in iter_flatten(iterable)]
    return a


def checken_if_tempbilder_noch_da():
    target_dir = "tempbilder"
    try:
        with os.scandir(target_dir) as entries:
            for entry in entries:
                if entry.is_dir() and not entry.is_symlink():
                    shutil.rmtree(entry.path)
                else:
                    os.remove(entry.path)
    except:
        pass


print(1000 * "\n")

maximize_console(lines=30000)
checken_if_tempbilder_noch_da()
add_color_print_to_regedit()
colorfunctionslogo = [drucker.f.black.red.normal, drucker.f.black.brightyellow.normal]
drucker.p_ascii_front_on_flag_with_border(
    text="Bilderraten",
    colorfunctions=colorfunctionslogo,
    bordercolorfunction=drucker.f.brightgreen.black.italic,
    font="slant",
    width=1000,
    offset_from_left_side=5,
    offset_from_text=15,
)
colorfunctionspage = [
    drucker.f.black.brightwhite.normal,
    drucker.f.black.brightgreen.normal,
]
drucker.p_ascii_front_on_flag_with_border(
    text="www . queroestudaralemao . com . br",
    colorfunctions=colorfunctionspage,
    bordercolorfunction=drucker.f.brightgreen.black.negative,
    font="slant",
    width=1000,
    offset_from_left_side=1,
    offset_from_text=1,
)

updates_quero_estudar_alemao()
allewoerter = vokabelliste_einlesen()
shuffle(allewoerter)
allebilderlinks = []
htmllinks = []
ocrscanner = WinRtBackend()
picturesize = 60
colorfunctions = [drucker.f.black.red.normal, drucker.f.black.white.normal]
gesamtpunktzahl = 0
for escapedwords in allewoerter:
    htmllinks = get_htmllinks_of_wort(escapedwords)
    gespeichertebilder = []
    allethreads = [
        kthread.KThread(target=bildspeichern, args=[xxx], name=xxx[0])
        for xxx in htmllinks
    ]
    allethreads2 = [k.start() for k in allethreads]
    nochamleben = [k.is_alive() for k in allethreads]
    nochamleben = [istda for istda in nochamleben if istda is True]
    t_end = time() + 10
    while any(nochamleben):
        if time() > t_end:
            for k in allethreads:
                try:
                    k.terminate()
                except:
                    continue
        sleep(0.1)
        nochamleben = [k.is_alive() for k in allethreads]
        nochamleben = [istda for istda in nochamleben if istda is True]

    brauchebarebilder = textrausschmeissen(gespeichertebilder)
    shuffle(brauchebarebilder)
    bilderstellen(brauchebarebilder)
    bildascii = drucker.p_picture_to_ascii_art(
        "tempbilder/endbild.png",
        letter_for_ascii_art="█",
        rgb8_16_256=256,
        desired_width=60,
    )
    print(bildascii)
    drucker.p_pandas_list_dict(specialkeysde, listtranspose=True)
    drucker.p_pandas_list_dict(specialkeyspt, listtranspose=True)
    langegesuchteswort = len(escapedwords[0]) * "_"

    drucker.p_ascii_front_on_flag_with_border(
        text=langegesuchteswort,
        colorfunctions=colorfunctions,
        bordercolorfunction=drucker.f.brightmagenta.brightcyan.negative,
        font="roman",
        width=1000,
        offset_from_left_side=5,
        offset_from_text=15,
    )

    antwort = str(
        input(
            drucker.f.brightyellow.black.bold(
                "\n                    What word are we looking for?            \n"
            )
        )
    ).strip()
    for key in allespecialkeys:
        antwort = antwort.replace(key[1], key[0])
    tippsgeben = True
    if antwort == escapedwords[0]:
        gesamtpunktzahl = gesamtpunktzahl + 1
        tippsgeben = False
    while tippsgeben is True:
        hint = (
            drucker.f.black.brightwhite.bold("\nIs it too hard? Do you need any tips? ")
            + drucker.f.black.yellow.bold("\nType ")
            + drucker.f.black.brightyellow.bold("?")
            + drucker.f.black.yellow.bold(" to see the next letter\n")
            + drucker.f.black.brightred.italic(
                "(Attention: special characters are usually not shown!)\n"
            )
        )
        print(hint)
        antwort = str(
            input(
                drucker.f.brightyellow.black.bold(
                    "\n                    What word are we looking for?            \n"
                )
            )
        ).strip()

        if antwort == "?":
            neueswortdrucken = []
            strichwort = flattenlist(langegesuchteswort)
            richtigeswort = flattenlist(escapedwords[0])
            for strichw, richtigesw in zip(strichwort, richtigeswort):
                if strichw == "_":
                    neueswortdrucken.append(richtigesw)
                    break
                if strichw != "_":
                    neueswortdrucken.append(richtigesw)
            neueswortdrucken.append((len(strichwort) - len(neueswortdrucken)) * "_")
            langegesuchteswort = "".join(neueswortdrucken)

            drucker.p_ascii_front_on_flag_with_border(
                text=langegesuchteswort,
                colorfunctions=colorfunctions,
                bordercolorfunction=drucker.f.brightmagenta.brightcyan.negative,
                font="roman",
                width=1000,
                offset_from_left_side=5,
                offset_from_text=15,
            )
            if "_" not in langegesuchteswort:
                break
        if antwort == escapedwords[0]:
            gesamtpunktzahl = gesamtpunktzahl + 1
            break
    punkzahldrucken = (
        drucker.f.green.brightwhite.bold(f"\n\nYour points: {gesamtpunktzahl} ")
        + drucker.f.black.brightwhite.bold(" of ")
        + drucker.f.brightwhite.green.bold(f"{len(allewoerter)} points  \n\n")
    )
    print(punkzahldrucken)
    delete_old_images()

add_color_print_reg.py

from json import loads as jsonloads
from os import name as osname
from sys import exit as sysexit
from textwrap import TextWrapper
from random import choice
from requests import get as requestsget
from farbprinter.farbprinter import Farbprinter

windowsrechner = osname == "nt"
from winregistry import WinRegistry
from winreg import HKEY_CURRENT_USER, KEY_READ, REG_DWORD

linebreakx = 50
wrapper = TextWrapper(width=linebreakx)
drucker = Farbprinter()
jsonqueroestudaralemao = "https://www.queroestudaralemao.com.br/wp-content/uploads/updateinformatioen/update.json"
logo_auswahl = auswahlliste = [
    drucker.f.brightred.black.bold,
    drucker.f.black.brightred.bold,
    drucker.f.yellow.black.bold,
    drucker.f.brightyellow.black.bold,
]
REGEDITPATH = r"HKEY_CURRENT_USER\Console"
regedit_success = "I think, it has worked out! Let's start"
virtualterminalregedit = "VirtualTerminalLevel"
able_to_see_col_text = "Everything is configured right! You should be able to see colored text! Please restart the app if you can't see colored text"
regedit_is_zero = "HKEY_CURRENT_USER\Console\VirtualTerminalLevel is set to 0! I will try to change it to 1 so that you can read colored text!"
regeditfail = """I was unable to change the Registry!\n Let\'s try it anyway!\n If you can\'t read the text in the terminal, add this to your Windows Registry:\n\n[HKEY_CURRENT_USER\Console]\n
"VirtualTerminalLevel"=dword:00000001"""
try_to_create_key = "HKEY_CURRENT_USER\Console\VirtualTerminalLevel not found! I will try to create it so that you can see colored text"


def add_color_print_to_regedit():
    if windowsrechner:
        try:
            with WinRegistry() as client:
                try:

                    regedit_entry = client.read_entry(
                        REGEDITPATH, virtualterminalregedit
                    )
                    if int(regedit_entry.value) == 1:
                        print(drucker.f.black.green.negative(able_to_see_col_text))
                        return True
                    if int(regedit_entry.value) == 0:
                        print(drucker.f.black.brightyellow.negative(regedit_is_zero))
                        try:
                            client.write_entry(
                                REGEDITPATH,
                                virtualterminalregedit,
                                value=1,
                                reg_type=REG_DWORD,
                            )
                            print(drucker.f.black.green.negative(regedit_success))
                        except:
                            print(drucker.f.black.brightred.negative(regeditfail))
                            return False
                except:
                    print(drucker.f.black.brightyellow.negative(try_to_create_key))
                    try:
                        client.write_entry(
                            REGEDITPATH,
                            "VirtualTerminalLevel",
                            value=1,
                            reg_type=REG_DWORD,
                        )
                        print(drucker.f.black.green.negative(regedit_success))

                        return True
                    except:
                        print(drucker.f.black.brightred.negative(regeditfail))
                        return False
        except:
            print(
                drucker.f.black.brightred.negative(
                    "Error checking if VirtualTerminalLevel is set to 1"
                )
            )


def updates_quero_estudar_alemao():
    choice(auswahlliste)("made by queroestudaralemao.com.br")
    print(
        drucker.f.black.brightblue.bold(
            "\n         Updates from https://www.queroestudaralemao.com.br :\n\n"
        )
    )

    jsoninhalt = requestsget(jsonqueroestudaralemao)
    j = jsonloads(jsoninhalt.text)

    for key, value in j.items():
        neuigkeitendatum = drucker.f.cyan.brightwhite.italic(
            f"""         {key} - News from    """.ljust(20).rjust(20)
        )
        print(neuigkeitendatum, end=" ")
        print(
            drucker.f.black.brightwhite.negative(f'       {value["autor"]}:        '),
            end=" ",
        )
        print(
            drucker.f.brightwhite.blue.negative(f'       {value["datum"]}:        '),
            end=" ",
        )
        neuigkeitenwrap = wrapper.wrap(text=value["neuigkeiten"])
        print("\n")
        for satz in neuigkeitenwrap:
            print(drucker.f.black.brightyellow.bold("     "), end="")
            ausfuellen = (70 - len(satz)) * " "
            print(
                drucker.f.black.brightyellow.bold(f"   {satz}   {ausfuellen}"), end="\n"
            )
        if value["online"] == "0":
            print(value["nachricht"])
            sysexit()
        print("\n")


maximize_console.py (obrigado https://stackoverflow.com/a/43959471/15096247 )

import os
import ctypes
import msvcrt
import subprocess
from ctypes import wintypes

kernel32 = ctypes.WinDLL("kernel32", use_last_error=True)
user32 = ctypes.WinDLL("user32", use_last_error=True)
SW_MAXIMIZE = 3
kernel32.GetConsoleWindow.restype = wintypes.HWND
kernel32.GetLargestConsoleWindowSize.restype = wintypes._COORD
kernel32.GetLargestConsoleWindowSize.argtypes = (wintypes.HANDLE,)
user32.ShowWindow.argtypes = (wintypes.HWND, ctypes.c_int)


def maximize_console(lines=None):
    fd = os.open("CONOUT$", os.O_RDWR)
    try:
        hCon = msvcrt.get_osfhandle(fd)
        max_size = kernel32.GetLargestConsoleWindowSize(hCon)
        if max_size.X == 0 and max_size.Y == 0:
            raise ctypes.WinError(ctypes.get_last_error())
    finally:
        os.close(fd)
    cols = max_size.X
    hWnd = kernel32.GetConsoleWindow()
    if cols and hWnd:
        if lines is None:
            lines = max_size.Y
        else:
            lines = max(min(lines, 9999), max_size.Y)
        subprocess.check_call("mode.com con cols={} lines={}".format(cols, lines))
        user32.ShowWindow(hWnd, SW_MAXIMIZE)

Artigos relacionados

Respostas

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *

Start a Conversation

Hi! Click one of our member below to chat on Whatsapp

Suporte técnico

Suporte técnico

Suporte técnico - mande uma mensagem!

online

Depois de muitos problemas de saúde, finalmente, estou de volta!

Há novas vagas nos cursos on-line