Spaces:
Running
Running
File size: 2,572 Bytes
fa9a583 cd5e862 fa9a583 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# Keywords.py
# Purpose: This file contains the functions to create the Keywords tab in the Gradio UI.
#
# The Keywords tab allows the user to add, delete, view, and export keywords from the database.
#
# Imports:
#
# External Imports
import gradio as gr
#
# Internal Imports
from App_Function_Libraries.DB.DB_Manager import add_keyword, delete_keyword, keywords_browser_interface, export_keywords_to_csv
#
#
######################################################################################################################
#
# Functions:
def create_export_keywords_tab():
with gr.Tab("Export Keywords"):
with gr.Row():
with gr.Column():
export_keywords_button = gr.Button("Export Keywords")
with gr.Column():
export_keywords_output = gr.File(label="Download Exported Keywords")
export_keywords_status = gr.Textbox(label="Export Status")
export_keywords_button.click(
fn=export_keywords_to_csv,
outputs=[export_keywords_status, export_keywords_output]
)
def create_view_keywords_tab():
with gr.TabItem("View Keywords"):
gr.Markdown("# Browse Keywords")
with gr.Column():
browse_output = gr.Markdown()
browse_button = gr.Button("View Existing Keywords")
browse_button.click(fn=keywords_browser_interface, outputs=browse_output)
def create_add_keyword_tab():
with gr.TabItem("Add Keywords"):
with gr.Row():
with gr.Column():
gr.Markdown("# Add Keywords to the Database")
add_input = gr.Textbox(label="Add Keywords (comma-separated)", placeholder="Enter keywords here...")
add_button = gr.Button("Add Keywords")
with gr.Row():
add_output = gr.Textbox(label="Result")
add_button.click(fn=add_keyword, inputs=add_input, outputs=add_output)
def create_delete_keyword_tab():
with gr.Tab("Delete Keywords"):
with gr.Row():
with gr.Column():
gr.Markdown("# Delete Keywords from the Database")
delete_input = gr.Textbox(label="Delete Keyword", placeholder="Enter keyword to delete here...")
delete_button = gr.Button("Delete Keyword")
with gr.Row():
delete_output = gr.Textbox(label="Result")
delete_button.click(fn=delete_keyword, inputs=delete_input, outputs=delete_output)
|