728x90
반응형

 티스토리 

기본 팝업창 예제로 공부해보자.

PySimpleGUI는 다양한 팝업 창을 포함하여 파이썬에서 GUI 어플리케이션을 만들기 위한 간단한 방법을 제공합니다. 다음은 PySimpleGUI에서 다양한 유형의 팝업 창을 사용하는 방법을 보여주는 예제 모음입니다. 자세한 문서와 더 많은 예제는 PySimpleGUI 공식 문서를 참고하세요.

1. Basic Popup ( 기본창 )

  The most basic form of popup to display a message:

가장 기본적인 팝업창 메세지 :

import PySimpleGUI as sg

sg.popup('CostZeroCode')

코드 실행결과(Output)

반응형

2. Popup with Title( 제목창이 있는 팝업창)

A popup window with a custom title:

import PySimpleGUI as sg

sg.popup('This is the main message', title='Custom Title')

3. Popup with Multiple Lines ( 여러줄로 메세지 출력하는 창)


To display multiple lines of text, you can separate text using a newline character \n:

여러개의 텍스트 라인으로 팝업창 생성

import PySimpleGUI as sg

sg.popup('Line 1\nLine 2\nLine 3', title='Multiple Lines')

코드 결과

 

4. Popup to Get User Input

To get input from the user through a popup:

import PySimpleGUI as sg

user_input = sg.popup_get_text('Please enter something')
sg.popup(f'You entered: {user_input}')

 

5. Popup to Show an Error ( 에러 메시지 창)

For showing error messages:

import PySimpleGUI as sg

sg.popup_error('An error has occurred!')

코드 실행결과

5. Popup to Display an OK/Cancel Dialog

To ask the user a yes/no question:

OK 또는 Cancel 버튼 선택창

import PySimpleGUI as sg

result = sg.popup_ok_cancel('Do you want to proceed?')
sg.popup(f'You chose: {result}')

코드 실행결과

 

6. Popup with Custom Button Text ( 사용자 정의 버튼과 결과 출력창)

To create a popup with custom button texts:

사용자 정의 버튼 과 선택한 버튼의 텍스트를 출력하는 팝업

import PySimpleGUI as sg

result = sg.popup('Custom button text example', button_type=sg.POPUP_BUTTONS_YES_NO, custom_text=('Proceed', 'Stop'))
sg.popup(f'You chose: {result}')

코드 실행결
버튼 클릭 결과

7. Popup for Folder Selection

To ask the user to select a folder:

import PySimpleGUI as sg

folder = sg.popup_get_folder('Please select a folder')
sg.popup(f'You selected: {folder}')

실행 결과

이 예제들은 PySimpleGUI에서 팝업의 기본 사용법을 다룹니다. 이 템플릿들로 실험해 보고 PySimpleGUI 문서를 확인하여 더 고급 기능과 사용자 정의 옵션을 알아보세요.

These examples cover basic usage of popups in PySimpleGUI. Experiment with these templates and check the PySimpleGUI documentation for more advanced features and customization options.

 

728x90

 

 

마무리

- 이번 포스팅은 PysimplgeGUI 기본 팝업창 생성에 대해 알아봤습니다.

CostZeroCode

 
 
 

궁금한 사항은 lution2@gmail.com로 문의사항  주시면 답변 드리겠습니다.
감사합니다.

 

 

728x90
반응형

+ Recent posts