tkinter를 사용하여 대화 상자를 만들고 싶다고 가정해 봅시다. 대화 상자를 만들려면 여러 기능이 포함된 MessageBox 라이브러리를 사용하여 대화 유형을 빠르게 만들 수 있습니다.
생성된 Dialogue Box의 위치를 조정하기 위해 기본적으로 현재 상자에 우선 순위를 부여하고 다른 모든 프로세스를 백엔드에 유지하는 "toplevel" 속성을 사용할 수 있습니다.
제목, 메시지 및 세부 정보와 같은 다른 기능이 포함되어 있습니다. MessageBox 위젯의 위치를 변경하려면 기하학을 사용합니다. 방법.
예시
#import the tkinter library
from tkinter import *
#define the messagebox function
def messagebox():
#toplevel function creates MessageBox dialog which appears on top of the screen
top=Toplevel(win)
top.title("Click Me")
#Define the position of the MessageBox
x_position = 600
y_position = 400
top.geometry(f"600x200+{x_position}+{y_position}")
#Define the property of the messageBox
l1=Label(top, text= "Hello! TutorialsPoint",bg= "green", fg=
"white",font=('Times New Roman', 24),height=50, width= 50).pack()
#Create an instance of the tkinter frame
#And resize the frame
win = Tk()
win.geometry("600x200")
win.title("Window-1")
Button(win, text="Click Me", command=messagebox,
width=8).pack(pady=80)
win.mainloop() 출력
위 코드를 실행하면 다음과 같은 출력 창이 생성됩니다.

"Click Me" 버튼을 클릭하면 다음 대화 상자가 열리고 나중에 배치할 수 있습니다.
