コード例 #1
0
def get_links(window):
    tasks = Queue()
    window.store.movies = {}
    [tasks.put(idx) for idx in range(1, 600)]

    def worker(label):
        while not tasks.empty():
            num = tasks.get()
            try:
                web = get(f'http://links.mega-estrenos.com/{num}/')
                bs = BeautifulSoup(web.content, 'html5lib')
                title = bs.h1.contents[0]
                links = bs.find_all('a', {'class': 'linkencio'})
                links = [idx.contents[0] for idx in links]
                links = [link for link in links if 'mega.nz' in link]
                if not links:
                    raise AttributeError
                label.value = green("Found: ") + title
                window.store.movies[title] = links[0]
            except (AttributeError, BaseHTTPError, IndexError):
                pass
            finally:
                tasks.task_done()
        tasks.join()
        window.close()

    window += Label(text=bold('Peliculas'), align='center', width=window.width)
    for idx in range(8):
        label = Label(text=f'Worker {idx}', cordy=idx + 1)
        thread = Thread(target=worker, args=(label, ))
        thread.start()
        window += label
コード例 #2
0
ファイル: nested_windows.py プロジェクト: avivgil/Tebless
def second_window(window, value):
    _label = Label(align='center', text=value, width=window.width)
    _input = Input(
        label='Introduce: ',
        cordy=3,
        on_enter=lambda sender: third_window(sender.value)
    )

    window += _label, _input
コード例 #3
0
ファイル: menu.py プロジェクト: avivgil/Tebless
def view_single_menu(window):
    def update_label(sender):
        sender.store.label.value = sender.value

    window += Menu(items=['Valor ' + str(x) for x in range(110)],
                   limit=8,
                   header='Menu',
                   footer='Pagina {page} de {last}',
                   on_change=update_label)
    window += Label(ref='label', cordy=10, text='mundo')
コード例 #4
0
def main(window):
    WIDTH, HEIGHT = window.size
    window += Label(text='CheckBox example', align='center', width=WIDTH)

    window += CheckBox(cordy=2, label=green('Element 1'))
    window += CheckBox(cordy=3, label=green('Element 2'), key=KEY_F2)
    window += CheckBox(cordy=4,
                       label=green('Element 3'),
                       key=KEY_F3,
                       check=lambda state: '(O)' if state else '( )')
コード例 #5
0
ファイル: nested_windows.py プロジェクト: avivgil/Tebless
def main(window):
    assert isinstance(window, Window)
    _label = Label(align='center', text="Example real world",
                   width=window.width)
    _input = Input(
        label='Introduce: ',
        cordy=3,
        on_enter=lambda sender: second_window(sender.value)
    )

    window += _label, _input
コード例 #6
0
ファイル: filter_menu.py プロジェクト: avivgil/Tebless
def main():
    store = Store()
    with Window(store=store) as win:
        win += Label(
            cordy=12,
            ref='label'
        )

        def change(sender):
            store.label.value = sender.value

        win += FilterMenu({
            'label': 'Filtrar: ',
            'validation': r'\d'
        }, {
            'cordy': 1,
            'items': [
                'Valor {:04d}'.format(randint(0, 1000)) for x in range(10000)
            ],
            'header': 'Lista',
            'footer': '{page}/{last}, Total: {count}',
            'on_enter': change
        })
コード例 #7
0
ファイル: movie_down.py プロジェクト: mdbetancourt/movie-down
def main(window):
    HEIGHT = window.height
    data = {}

    if len(sys.argv) > 1:
        file_url = sys.argv[1]
    else:
        user = os.path.expanduser("~")
        file_url = '.links-movies.json'
        file_url = os.path.join(user, file_url)
    try:
        with open(file_url) as file:
            data = json.load(file)
    except IOError:
        get_links(store=window.store)
        with open(file_url, 'w') as file:
            json.dump(window.store.movies, file, indent=2)
            data = window.store.movies
    inf_label = Label(text='Link', cordy=HEIGHT - 2)

    def open_link(link):
        inf_label.value = f'Opened {link}'
        webbrowser.open(link)

    window += FilterMenu(
        {
            'max_len': 20,
            'label': "Pelicula: "
        }, {
            'cordy': 1,
            'limit': HEIGHT - 3,
            'items': sorted(data.keys()),
            'on_enter': lambda sender: open_link(data[sender.value])
        })

    window += inf_label
コード例 #8
0
ファイル: nested_windows.py プロジェクト: avivgil/Tebless
def third_window(window, value):
    assert isinstance(window, Window)
    window += Label(align='center', text=value, width=window.width)
    window.timeout(window.close, time=3)