콘텐츠로 이동

메세지 팝업창 표시

필요한 모듈 설치

!pip install gradio

메시지를 표시하는 방법

import gradio as gr

# 버튼 클릭 시 실행될 함수 정의
def button1_action():
    gr.Info("참 잘했어요.", duration=5)

def button2_action():
    gr.Warning("이상한 버튼을 클릭하였습니다.", duration=5) 

def button3_action():
    raise gr.Error("버튼을 잘못 눌렀습니다.", duration=5)


# Blocks 사용하여 인터페이스 생성
with gr.Blocks() as demo:    
    with gr.Row():
        button1 = gr.Button("Info")
        button2 = gr.Button("Warning")
        button3 = gr.Button("Error")

    # 각 버튼에 클릭 이벤트와 출력 연결
    button1.click(fn=button1_action)
    button2.click(fn=button2_action)
    button3.click(fn=button3_action)

# 인터페이스 실행
demo.launch()