import os
from src.dft_data_to_grphs import MaterialDS, MaterialMesh, MyTensor
os.environ['KMP_DUPLICATE_LIB_OK'] = 'True'

import gradio as gr
from interface_connection import upload_struct, compute_mat

with gr.Blocks() as latmatcher:
    gr.Markdown(
        "\n Please drop your XYZ files here to compute the minimum supercell.")

    with gr.Tabs():
        with gr.TabItem(label="Hamiltonina Wizard"):
            with gr.Row():
                with gr.Column(scale=1, min_width=400):
                    example_file_a = gr.Dropdown(
                        ["aBN_01", "aBN_02", "hBN"], value=[], multiselect=True, label="Select a structure",
                        info="."
                    )

                with gr.Column(scale=1, min_width=400):
                    load_structure_button = gr.Button("Upload your own structure.")

            with gr.Row():
                with gr.Column(scale=1, min_width=400):
                    h_matrix_plot = gr.Plot()

                with gr.Column(scale=1, min_width=400):
                    s_matrix_plot = gr.Plot()

            #neighbour_radius = gr.Slider(5, 100, label=" Radius:", step=1, value=5)
            select_modle = gr.Dropdown(
                ["wizard 0.3",], value=["wizard 0.3"], multiselect=True, label="Select a structure",
                info="."
            )

            compute_button = gr.Button("Compute Hamiltonian and S matrix ")
            file_material_ab = gr.File(label="Result  h_mat, s_mat", )

            load_structure_button.click(upload_struct,
                                        inputs=[],
                                        outputs=[])

            compute_button.click(compute_mat,
                                 inputs=[example_file_a, select_modle],
                                 outputs=[h_matrix_plot, s_matrix_plot,file_material_ab ])

latmatcher.launch(share=True)