Implement simple python UI
This commit is contained in:
parent
ab2e1fc1d9
commit
bef59fd760
56
src/main.py
Normal file
56
src/main.py
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
from nicegui import ui
|
||||||
|
import time
|
||||||
|
|
||||||
|
ui.dark_mode().enable()
|
||||||
|
|
||||||
|
def add_nhentai_id():
|
||||||
|
id_value = id_input.value
|
||||||
|
if not id_value:
|
||||||
|
ui.notify('Please enter an ID', color='warning')
|
||||||
|
return
|
||||||
|
|
||||||
|
# Clear the input field after submission
|
||||||
|
id_input.value = ''
|
||||||
|
|
||||||
|
# Show notification
|
||||||
|
ui.notify(f'Adding nhentai ID: {id_value}')
|
||||||
|
|
||||||
|
# Create a new history item
|
||||||
|
with history_container:
|
||||||
|
item_row = ui.row().classes('w-full items-center')
|
||||||
|
with item_row:
|
||||||
|
status = ui.icon('circle').classes('text-yellow-500') # Initial "processing" status
|
||||||
|
ui.label(f'ID: {id_value}').classes('text-lg ml-2')
|
||||||
|
timestamp = ui.label(f'Added: {time.strftime("%H:%M:%S")}').classes('text-sm text-gray-500 ml-auto')
|
||||||
|
|
||||||
|
# Add a button to mark as success
|
||||||
|
ui.button('Mark Complete',
|
||||||
|
on_click=lambda: update_status(status, id_value, True),
|
||||||
|
color='green').classes('ml-2').props('size=sm')
|
||||||
|
|
||||||
|
def update_status(status_icon, id_value, success=True):
|
||||||
|
if success:
|
||||||
|
status_icon.name = 'check_circle'
|
||||||
|
status_icon.classes('text-green-500', remove='text-yellow-500')
|
||||||
|
ui.notify(f'ID {id_value} marked as complete', color='positive')
|
||||||
|
else:
|
||||||
|
status_icon.name = 'error'
|
||||||
|
status_icon.classes('text-red-500', remove='text-yellow-500')
|
||||||
|
ui.notify(f'ID {id_value} marked as failed', color='negative')
|
||||||
|
|
||||||
|
ui.label('nhentai ID Tracker').classes('text-2xl font-bold mb-4')
|
||||||
|
|
||||||
|
# Input and button row
|
||||||
|
with ui.row().classes('w-full items-center'):
|
||||||
|
id_input = ui.input(label='ID:').classes('mr-2')
|
||||||
|
ui.button('Add ID!', on_click=add_nhentai_id).props('icon=add')
|
||||||
|
|
||||||
|
# History section
|
||||||
|
ui.label('History').classes('text-xl font-bold mt-4 mb-2')
|
||||||
|
history_container = ui.column().classes('w-full border rounded-lg p-2')
|
||||||
|
|
||||||
|
# Add some instructions initially
|
||||||
|
with history_container:
|
||||||
|
ui.label('Enter an ID and click "Add ID!" to see the history').classes('text-gray-500 italic')
|
||||||
|
|
||||||
|
ui.run()
|
Loading…
x
Reference in New Issue
Block a user