PySide6 Getting Started Examples

repository·main·Indexed 41 days ago

https://github.com/erriez/pyside6-getting-started

A collection of minimal, self-contained Python 3 examples for learning PySide6 (Qt for Python) GUI development. Covers core functionality, layout management (QVBoxLayout, QHBoxLayout, QGridLayout), menu and toolbar implementation, dialogs, widgets, custom drawing with QPen and QBrush, system tray icons, and integration with Qt Creator.

Tokens
5.5K
Snippets
35
Records
48
Agent score
51%

What's inside PySide6 Getting Started

  1. Overview of PySide6 Getting Started

    main

    This project provides simple, self-contained Python 3 examples for developing Qt applications using PySide6. It is designed for educational purposes, focusing on PySide6 fundamentals without external runtime dependencies, networking, or complex deployment logic.

    Key Specifications:

    • Python Version: 3.10+
    • PySide6 Version: 6.7.2
    • Supported Platforms: Windows 10/11, Linux (Ubuntu 22.10 Wayland, x64, and Raspberry Pi OS).
    • Scope: Minimalist examples for learning; does not include packaging tools like PyInstaller or Nuitka.
  2. Explore PySide6 Getting Started examples

    main

    This repository provides a series of progressive Python examples to help you learn the basics of PySide6. The examples cover common GUI tasks including:

    • Simple Example: Basic application structure.
    • Window Icon: How to set an icon for your application window.
    • Tooltip: Implementing tooltips for UI elements.
    • Closing a Window: Handling window closure events.
    • Window Center: Centering a window on the screen.
    • Window Button: Working with buttons and signals.
    • Window Hide/Min/Max: Controlling window visibility and state (minimizing/maximizing).
  3. Run a PySide6 example on Windows

    main

    To execute one of the provided examples on Windows, you must first activate the virtual environment where the dependencies are installed, then run the specific Python script using the python command.

    # Activate virtual environment
    venv\Scripts\activate.bat
    
    # Run an example
    (venv) > python 01_gettings_started\01_simple_example.py
  4. Install VSCode extensions for PySide6 development

    main

    To develop PySide6 applications in Visual Studio Code, ensure you have the following extensions installed:

    • Python (Microsoft)
    • Pylance (Microsoft)
    • Debugger for Python (bundled with the Python extension)
    • Qt for Python (optional, provides syntax highlighting)",
  5. View PySide6 Qt Core examples

    main

    This directory contains example scripts demonstrating core PySide6 functionality.

    • 01_qtimer_singleshot.py: Demonstrates the use of QTimer.singleShot(), which is used to trigger a function or slot after a specified delay.
    • 02_pyside_version.py: Demonstrates how to programmatically check the installed PySide6 version.
  6. Explore PySide6 Wizard examples

    main

    The 09_wizard directory contains examples of implementing wizard-style interfaces using PySide6. These examples demonstrate how to structure multi-step workflows.

    • 01_trivial_wizard.py: A basic, minimal implementation of a wizard interface.
    • 02_license_wizard.py: A more complex implementation, likely demonstrating license agreements or more advanced step-based logic.
  7. Configure debugging for PySide6 in VSCode

    main

    To enable debugging, create a launch.json file:

    1. Open the Run and Debug view (Ctrl+Shift+D).
    2. Click Create a launch.json file.
    3. Select Python: Current File.

    This creates a configuration that allows you to run the currently active Python file in the integrated terminal.

    {
        "version": "0.2.0",
        "configurations": [
            {
                "name": "Python: Current File",
                "type": "python",
                "request": "launch",
                "program": "${file}",
                "console": "integratedTerminal"
            }
        ]
    }
  8. Setup and Debugging Guides

    main

    To use these examples, follow the platform-specific setup instructions and debugging guides provided in the repository:

    Environment Setup:

    • Linux: See SETUP_LINUX.md
    • Windows: See SETUP_WINDOWS.md
    • macOS: Not supported.

    Debugging Configuration:

    • Visual Studio Code: See SETUP_VSCode.md (Supports Windows and Linux).
    • PyCharm: See SETUP_PyCharm.md (Supports Windows and Linux).
  9. Explore PySide6 Desktop Application Examples

    main

    This section of the repository provides practical examples of building desktop applications using PySide6. The examples demonstrate common desktop functionality including system information retrieval, clipboard interaction, and settings management.

    Available examples:

    • 01_system_info.py: Demonstrates how to display system information in a desktop window.
    • 02_clipboard.py: Demonstrates interacting with the system clipboard.
    • 03_settings.py: Demonstrates managing application settings.
  10. Available PySide6 Learning Examples

    main

    The repository contains a series of focused examples covering various Qt concepts. You can explore these by navigating to their respective directories:

    • Core & Basics: 00 Qt Core, 01 Getting Started, 02 Messagebox, 03 Layout Management, 05 Events and Signals
    • UI Components: 04 Menu's and Toolbars, 06 Dialogs, 07 Widgets, 08 Widgets Specifics, 09 Wizard, 12 Custom Widgets, 14 System tray, 19 Tables
    • Advanced Interaction: 10 Drag and Drop, 11 Drawing, 15 Miscellaneous, 16 Games, 17 Desktop Applications
    • Tools & Deployment: 13 Qt Creator, 18 Deployment
  11. Explore PySide6 Widget Examples

    main

    This directory contains a collection of standalone Python scripts demonstrating the usage of various PySide6 widgets. Each example provides a visual and functional implementation of a specific UI component.

    Available widget examples include:

    • Checkbox: 01_checkbox.py
    • Toggle Buttons: 02_toggle_buttons.py
    • Slider: 03_slider.py
    • Progress Bar: 04_progressbar.py
    • Calendar: 05_calendar.py
    • QPixmap (Images): 06_qpixmap.py
    • LineEdit (Text Input): 07_lineedit.py
    • Splitter: 08_splitter.py
    • ComboBox: 09_combobox.py
    • Standard Icons: 10_standard_icons.py
    • Dial: 11_dial.py
    • Context Menu: 12_context_menu.py
    • Tabs: 13_tabs.py