ebook-downloader/gui.py

18 lines
656 B
Python
Raw Permalink Normal View History

2023-03-29 01:41:47 +00:00
from nicegui import *
from bookrequest import *
import configparser
config = configparser.ConfigParser()
try:
config.read('config.ini')
except Exception as e:
print(e)
print('Config file not found. Please ensure conf.ini is in the same \
location as bookrequest.py')
2023-03-29 01:41:47 +00:00
def pass_command() -> None:
if title.value != '':
result = searchBook(title.value, unattended=True)
ui.notify('Searching and Downloading Book!')
downloadBook(result)
with ui.card().classes('absolute-center'):
title = ui.input('Title').on('keydown.enter', pass_command)
ui.run(host=config['data']['host'],port=int(config['data']['port']))