TkEasyGUI

repository·main·Indexed 43 days ago

https://github.com/kujirahand/tkeasygui-python

A lightweight, easy-to-use GUI library for Python 3 built on top of Tkinter. It provides a simplified API for windows, widgets, and dialogs, and is designed to be compatible with the event-driven model of PySimpleGUI. Version 1.0.45 includes modules for dialogs, widgets, and utilities, supporting both modern ttk and classic tk rendering styles.

Tokens
64.1K
Snippets
187
Records
287
Agent score
54%

What's inside TkEasyGUI

  1. Explore TkEasyGUI Modules and Elements

    main

    TkEasyGUI is organized into several functional modules that allow you to build GUI applications using popups, standard widgets, and utilities:

    • dialogs module: Used for creating popup dialogs (e.g., popup, popup_get_file).
    • widgets module: Contains the core elements used to build windows and layouts (e.g., Window, Button, Input, Text).
    • utils module: Provides helper functions like get_clipboard and set_clipboard.
    • Custom Events: Allows for implementing specialized event handling logic.
  2. Use Push for element alignment

    main

    The Push element is used to achieve right alignment or center alignment within a layout by acting as a flexible spacer.

    • To right-align an element: Place sg.Push() before the element.
    • To center-align an element: Place sg.Push() both before and after the element.
    win = sg.Window(
        title="Hello World",
        layout=[
            [sg.Text("=" * 50)],
            [sg.Push(), sg.Button("Hello World")],  # right alignment
            [sg.Push(), sg.Button("OK"), sg.Push()], # center alignment
        ]
    )
    while win.is_running():
        event, values = win.read()
  3. How TkEasyGUI relates to PySimpleGUI

    main

    TkEasyGUI is designed to be compatible with the event-driven model of PySimpleGUI.

    • Compatibility: Basic functionalities and the event loop model (window.read()) are compatible.
    • Component Names: Basic GUI component names are kept the same, though some property names may differ.
    • Implementation: It is a complete re-implementation from scratch and is licensed under the MIT License.
    • Note: Full compatibility with PySimpleGUI is not intended; it is a separate library that follows similar patterns.
  4. Common methods for VPush and VSeparator

    main

    Both VPush and VSeparator share a standard set of methods for interaction and lifecycle management:

    • bind(event_name, handle_name, propagate=True, event_mode='user'): Binds a specific event to a handler.
    • bind_events(events: dict[str, str], event_mode='user'): Binds multiple user events. If an event key has the suffix /hide, it will not be returned to the user via window.read().
    • update(**kw): Updates the widget configuration.
    • focus() / focus_set(): Sets focus to the element.
    • get(): Retrieves the current value of the widget.
    • set_disabled(disabled: bool): Enables or disables the widget.
    • get_height() / get_width(): Returns the current dimensions of the element.
    • get_name(): Returns the element's key.
  5. Understand the relationship between TkEasyGUI and PySimpleGUI

    main

    TkEasyGUI is inspired by PySimpleGUI and is designed to be compatible with its event model and basic GUI component names.

    Key points:

    • Event Model: You can use the same event-driven programming pattern as PySimpleGUI.
    • Component Names: Basic GUI component names are consistent with PySimpleGUI.
    • Implementation: It is a completely fresh implementation from scratch, not a wrapper, meaning there are no licensing issues related to PySimpleGUI, though it does not aim for 100% feature parity or attribute name compatibility.
  6. Understand TkEasyGUI's relationship with PySimpleGUI

    main

    TkEasyGUI is designed to be intuitive for users familiar with PySimpleGUI.

    Compatibility:

    • The event model and many basic GUI components are compatible with PySimpleGUI.
    • Many element names are identical.

    Differences:

    • TkEasyGUI is a ground-up implementation with an MIT license.
    • Some property names differ from PySimpleGUI.
    • TkEasyGUI includes unique features like window.event_iter() for cleaner event loops, specialized popups (eg.popup_buttons, eg.popup_color, eg.popup_get_form), and enhanced Image support (JPEG in addition to PNG).
  7. Bind user events in FileSaveAs

    main

    You can use bind_events to map specific user actions to event keys. This is useful for reacting to changes in the file selection process.

    Note on /hide suffix: If you attach the suffix /hide to an event key in your mapping, that specific event key will be suppressed and will not be returned to the user during window.read() calls.

    # Example concept of binding events
    # widget.bind_events({"event_key": "handler_name"})
  8. How TkEasyGUI compares to PySimpleGUI

    main

    TkEasyGUI is designed to be compatible with the PySimpleGUI event model, making it easy for developers to switch.

    Key similarities and differences:

    • Event Model: Uses the same event-driven model (e.g., event, values = window.read()).
    • Element Names: Most basic GUI component names are identical.
    • Attributes: Some property names may differ.
    • Implementation: TkEasyGUI is a completely new implementation under the MIT license.
    • Features: Includes enhanced features like window.event_iter(), custom popups (eg.popup_color), and support for JPEG in the Image class.
  9. Explore TkEasyGUI submodules

    main

    TkEasyGUI is organized into several submodules that handle specific GUI functionalities:

    • TkEasyGUI.dialogs: For creating popup dialogs (e.g., text or input dialogs).
    • TkEasyGUI.widgets: Core UI components.
    • TkEasyGUI.widgets_image: Image-based widgets.
    • TkEasyGUI.widgets_window: Window-related widget management.
    • TkEasyGUI.locale_easy: Localization and easy language handling.
    • TkEasyGUI.utils: Utility functions.
    • TkEasyGUI.version: Version information.
  10. Install TkEasyGUI

    main

    You can install TkEasyGUI via PyPI or directly from the GitHub repository.

    Requirements:

    • Python 3.9 or higher.
    • Works on Windows, macOS, and Linux (any environment where Tkinter is available).

    Note for Raspberry Pi users:

    • Ensure you use Python 3.9+.
    • Install Pillow instead of PIL: pip install --upgrade --force-reinstall pillow.
    • Ensure python3-tk is installed: sudo apt-get install python3-tk.
    # From PyPI
    python -m pip install TkEasyGUI
    
    # From GitHub
    python -m pip install git+https://github.com/kujirahand/tkeasygui-python