SpeedColomiers / app.py
samuel-lunii's picture
unseen persons meet at the end
c7acbec
import gradio as gr
import pandas as pd
import numpy as np
from itertools import combinations
from math import ceil
from threading import Thread, Timer
from speed_dating_scheduler import SpeedDatingScheduler
import time
scheduler = SpeedDatingScheduler()
def display_participants(participants_list):
print(np.concatenate(participants_list, axis = 0))
global current_time
current_time = 0
global previous_time
previous_time = 1
def reset_timer():
global current_time
current_time = 121
return "120"
def update_timer():
global previous_time
global current_time
if time.time() - previous_time >= 0.9 :
current_time -= 1
previous_time = time.time()
current_time = max(0, current_time)
return str(current_time)
with gr.Blocks() as interface:
gr.Markdown("## Speed Business")
with gr.Row():
with gr.Column():
participants_list = gr.Dataframe(label="Participants",
headers=["Noms des participant路e路s"],
datatype=["str"],
type = "array",
row_count=32, # Ajustez selon les besoins
col_count=(1, "fixed"),
interactive=True)
validate_button = gr.Button("Valider la liste de participant路e路s")
with gr.Column():
current_round_label = gr.Markdown("")
get_next_round_button = gr.Button("Afficher le prochain placement")
schedule = gr.Dataframe(label="Planning des rencontres",
headers=["Table","Participant路e路s"],
datatype=["number", "str"],
row_count=20, # Ajustez selon les besoins
col_count=2,
interactive=False)
get_next_speech_turn_button = gr.Button("Afficher le prochain tour de parole")
participants_list.change(fn=scheduler.set_participants, inputs=[participants_list], outputs=[])
validate_button.click(fn=scheduler.schedule, inputs=[], outputs=[current_round_label])
get_next_round_button.click(fn=scheduler.get_next_round, inputs=[], outputs=[schedule, current_round_label])
get_next_speech_turn_button.click(fn=scheduler.get_next_speech_turn_style, inputs=[schedule], outputs=[schedule])
timer_button = gr.Button("Start")
timer_label = gr.Label("120",label="Chronom猫tre", scale = 30)
timer_start = interface.load(update_timer,
inputs=[],
outputs=[timer_label],
every=1)
timer_button.click(reset_timer, outputs=[timer_label])
interface.queue().launch()