import pre import gradio as gr import preset_fn def save(preset_name, artist_name, group_name, company_name, top_logo_img, qr_logo_img, sign_img1, sign_img2, sign_img3, sign_img4, sign_img5, sign_img6, sign_img7, sign_img8, sign_img9, sign_img10, sign_img11, sign_img12, userid, user_name): group_name_radio = gr.Radio(choices=pre.groups, label="Group Name") member_name_dropdown = gr.Dropdown(choices=pre.names, label="Member Name", allow_custom_value=True) logo_radio = gr.Radio(choices=pre.groups, label="Add Logo", interactive=True, value="None") sign = gr.Dropdown(choices=pre.names, label="Sign", type='index') qr_Logo_radio = gr.Radio(["tripleS", "None"], label="QR Logo", value="None", interactive=True) signs = [sign_img1, sign_img2, sign_img3, sign_img4, sign_img5, sign_img6, sign_img7, sign_img8, sign_img9, sign_img10, sign_img11, sign_img12] if any(arg is None for arg in (preset_name, artist_name, group_name, company_name, top_logo_img, qr_logo_img)): gr.Warning("Fill all blank") return group_name_radio, member_name_dropdown, logo_radio, sign, qr_Logo_radio, sign_img1, sign_img2, sign_img3, sign_img4, sign_img5, sign_img6, sign_img7, sign_img8, sign_img9, sign_img10, sign_img11, sign_img12 for i in range(len(artist_name)): if signs[i] is None: gr.Warning("Fill all blank") return group_name_radio, member_name_dropdown, logo_radio, sign, qr_Logo_radio, sign_img1, sign_img2, sign_img3, sign_img4, sign_img5, sign_img6, sign_img7, sign_img8, sign_img9, sign_img10, sign_img11, sign_img12 group_name_radio = gr.Radio(choices=[group_name] + pre.groups_Other, label="Group Name", value=group_name) member_name_dropdown = gr.Dropdown(choices=artist_name, label="Member Name", allow_custom_value=True, value=artist_name[0]) logo_radio = gr.Radio(choices=[group_name] + pre.groups, label="Add Logo", interactive=True, value=group_name) sign = gr.Dropdown(choices=artist_name + pre.names, label="Sign", type='index', value=artist_name[0]) qr_Logo_radio = gr.Radio([group_name] + ["tripleS", "None"], label="QR Logo", value=group_name, interactive=True) preset_id = preset_fn.create(userid, user_name, preset_name, group_name, artist_name, company_name, top_logo_img, qr_logo_img, sign_img1, sign_img2, sign_img3, sign_img4, sign_img5, sign_img6, sign_img7, sign_img8, sign_img9, sign_img10, sign_img11, sign_img12) folders = preset_fn.refresh_folder() preset = gr.Dropdown(choices=folders, value=preset_id) return group_name_radio, member_name_dropdown, logo_radio, sign, qr_Logo_radio, preset