Frontend Development 7 min read

Creating Various PySimpleGUI Pop‑up Windows and a Simple File Compression Tool in Python

This tutorial demonstrates how to install PySimpleGUI, use its one‑shot and persistent window patterns, employ a range of popup functions for messages, text, input, file/folder selection, and progress bars, and combine them to build a lightweight Python compression utility.

Python Programming Learning Circle
Python Programming Learning Circle
Python Programming Learning Circle
Creating Various PySimpleGUI Pop‑up Windows and a Simple File Compression Tool in Python

PySimpleGUI is a lightweight Python library that simplifies the creation of graphical user interfaces, making it ideal for automation tasks and quick prototyping.

Install the library with pip install pysimplegui and verify the installation by importing it in a Python session.

The library supports two window design patterns: a one‑shot window that appears once for alerts or data collection, and a persistent window that remains open until the user closes it, typically serving as the main interface.

Common popup functions include sg.popup('Message') , sg.popup_ok('OK button') , sg.popup_yes_no('Yes/No') , sg.popup_cancel('Cancel') , sg.popup_error('Error') , and sg.popup_auto_close('Auto‑close') , each customizable with parameters such as title, colors, and button labels.

For scrolling text, use sg.popup_scrolled(text, title='Title') , which automatically adds a scrollbar when the content exceeds the window size.

To capture user input, employ sg.popup_get_text('Prompt') or sg.popup_get_text('Prompt', password_char='*') for hidden password entry, with the returned value being None if the user cancels.

File and folder selection dialogs are provided by sg.popup_get_file() and sg.popup_get_folder() , allowing users to choose paths that are then returned to the program for further processing.

A progress bar can be displayed with sg.one_line_progress_meter('Title', i+1, total, 'Key', 'Description') , supporting orientation and color customization.

Combining these dialogs, the tutorial builds a simple compression tool: it first asks the user to select a folder, then to choose a destination zip file (using save_as=True and default_extension='zip' ), compresses the folder contents with the zipfile module, and finally shows the resulting archive size using sg.popup(f'Compressed size: {size} KB') .

GUIfile compressionPopupPySimpleGUI
Python Programming Learning Circle
Written by

Python Programming Learning Circle

A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.