Esempio n. 1
0
def get_video():
    link = get_link_val()
    try:
        video = YouTube(str(link))
        title = video.title
        thumbnail_response = requests.get(video.thumbnail_url)
        img = Image.open(BytesIO(thumbnail_response.content))
        quality = video.streams.filter(progressive=True)
        global selected_quality
        selected_quality = [items.resolution for items in quality]
    except pytube.exceptions.RegexMatchError:
        #global video_box
        video_box.width = "fill"
        guizero.Text(video_box, text=" ")
        txt = guizero.Text(video_box,
                           text="Please enter a valid YouTube video link")
    except urllib.error.URLError:
        video_box.width = "fill"
        guizero.Text(video_box, text=" ")
        txt = guizero.Text(
            video_box,
            text="Please check your internet connection and try again")
        guizero.Text(video_box, text=" ")
        global try_again
        try_again = guizero.PushButton(app,
                                       text="Try again",
                                       command=start_download_thread)
        guizero.Text(app, text=" ")
    else:
        #global video_box
        picture_box = guizero.Box(video_box,
                                  align="left",
                                  width=100,
                                  height="fill")
        info_box = guizero.Box(video_box,
                               align="right",
                               width=display_width - 100,
                               height="fill")
        thumbnail = guizero.Picture(picture_box,
                                    image=img,
                                    align="left",
                                    width=100,
                                    height=100)
        title = guizero.Text(info_box, text=title, width="fill")
        download_box = guizero.Box(info_box, width=75, height=50)
        global qualities
        download_btn = guizero.PushButton(download_box,
                                          text="Download",
                                          command=download_video,
                                          args=[
                                              quality[selected_quality.index(
                                                  qualities.value)],
                                              os.getcwd(), title
                                          ])
        qualities = guizero.ListBox(
            info_box,
            items=[item.resolution for item in quality],
            width=100,
            height=100)
    loading_text.destroy()
Esempio n. 2
0
def open_image():
    global input_box
    global return_box
    metadata = None
    return_box = guizero.Box(app, width="fill")
    try:
        # using PIl to open image
        img = Image.open(input_box.value)
        # opening pyexiv2 instance from image
        meta = Meta(input_box.value)
        # opening the instance like this so that we don't close it after reading metadata so object is still in memory, although this can cause a memory leak

        # with Meta(input_box.value) as meta: -> using this method will delete the object and we will no longer have access to it in the clear meta function
        metadata = meta.read_exif()
        message = guizero.Text(return_box, text="")
        thumbnail = guizero.Picture(return_box,
                                    image=img,
                                    width=100,
                                    height=100)
        message = guizero.Text(return_box, text="")
        if not metadata:
            # picture has no metadata
            listbox = guizero.ListBox(return_box,
                                      items=["No metadata was extracted"],
                                      width="fill",
                                      height=50)
        else:
            listbox = guizero.ListBox(return_box, items=[], width="fill")
            cancel = guizero.PushButton(buttons_box,
                                        text="Strip Metadata",
                                        align="right",
                                        command=clear_meta,
                                        args=[meta])
            for _ in metadata.items():
                # add each item in metadata to listbox
                listbox.append(f"{_[0]}:     {_[1]}")
    except FileNotFoundError:
        message = guizero.Text(return_box, text="")
        thumbnail = guizero.Picture(return_box,
                                    image=f'error.jpeg',
                                    width=200,
                                    height=200)
        message = guizero.Text(return_box, text="")
        message = guizero.Text(return_box, text="Image not found")
Esempio n. 3
0
def visualize(matrix, steps, image, desktop, n_step):
    windows = guizero.Window(desktop,
                             layout='grid',
                             visible=False,
                             title='End')
    dictionary = {'X': 'black', 'o': 'green', ' ': 'white', 'v': 'yellow'}
    global n_steps
    n_steps = n_step
    global xd
    global yd
    y = 14
    xd, yd = location('o', matrix)
    road = {}
    for iy in range(15):
        for ix in range(20):
            road[ix, iy] = guizero.Picture(windows, image=image, grid=[ix, y])
            road[ix, iy].bg = dictionary[matrix[ix, iy]]
        y -= 1
    windows.show(wait=True)
    guizero.PushButton(
        windows,
        text='Go forward',
        grid=[(ix + 1), 0],
        command=lambda: forward(steps, road, int(len(steps)), windows))
Esempio n. 4
0
import os
import guizero as gui
from src import recognition as rcgTrigger

imagem = 0

app = gui.App(title="Reconhecimento de escrita a mão - Machine Learning")
img_window = gui.Picture(app)


def getCursives():
    dados = os.listdir('./assets/')
    del dados[dados.index('.directory')]
    return dados


def imgValue(valor):
    global imagem, img_window
    imagem = valor
    img_window.value = "./assets/" + valor
    img_window.height = 56
    img_window.width = 56
    print(valor)


listbox = gui.ListBox(app, items=getCursives(), scrollbar=True, command=imgValue, align="center")

listbox.bg = "#ffffff"
listbox.text_color = "#000000"

Esempio n. 5
0
MAIN_APP_LAYOUT = "grid"

mainApp = guizero.App(MAIN_APP_TITLE, SCREEN_WIDTH, SCREEN_HEIGHT,
                      MAIN_APP_LAYOUT)

mainApp.tk.wm_iconbitmap('images/space.ico')

titleText = guizero.Text(
    mainApp,
    "Adjust the sliders to match the wormhole you're looking at:",
    size=20,
    grid=[0, 0])

wormholeEyeImage = guizero.Picture(mainApp,
                                   "images/c1.bmp",
                                   grid=[0, 1],
                                   width=250,
                                   height=250)


def switchWormholeEye():
    wormholeEyeImage.image = "images/c{}.bmp".format(wormholeEyeSlider.value)


wormholeEyeSlider = guizero.Slider(mainApp,
                                   start=1,
                                   end=6,
                                   horizontal=True,
                                   command=switchWormholeEye,
                                   grid=[0, 2])
Esempio n. 6
0
def change_to_custom():
    """Changes the date option radio button selection to 'custom.'"""
    date_option_button_list = date_option.children
    date_option_button_list[1].tk.select()


# Widgets -----

# # Header Box
header_box = gui.Box(app, grid=[0, 0, 3, 1], width=510, height=80)

header_sub_box = gui.Box(header_box)
pixela_logo = gui.Picture(header_sub_box,
                          image='images/PIXELA_RED.png',
                          width=60,
                          height=60,
                          align='left')
header_text = gui.Text(header_sub_box,
                       text='Habit Tracker',
                       align='right',
                       size=48)

# # Graph Properties Box
graph_properties_box = gui.Box(app,
                               grid=[0, 1, 3, 1],
                               width=510,
                               height=60,
                               layout='grid')

username_box = gui.Box(graph_properties_box, grid=[0, 0], width=150, height=60)