Skip to main content

Immediate mode GUI library

Project description

pyegui

pyegui is a native extenstion for Python that provides bindings for Rust immediate mode GUI library egui.

Example

from pyegui import *

name = Str("Van")
age = Int(24)

def update_func(ctx):
  heading("My egui Application")
  text_edit_singleline(name, hint_text="Your name")
  slider_int(age, 0, 150, "age")

  if button_clicked("Increment"):
    age.value += 1

  heading(f"Hello '{name.value}', age {age.value}")
  image("file://image.png", max_width=350, max_height=250)

run_native("My pyegui Application", update_func)

example 1 example 2

Features

pyegui tries to be as close as possible to the original egui API, but with the focus on simplicity and usability. Callbacks were removed where possible to accomplish more smooth expirience in Python.

  • Light and Dark themes(defaults to the system's)
  • Built-in latin and cyrillic alphabets. You can load any font you want with ctx.set_font function
  • Images(png and jpeg)
  • Date picker
  • RBG color picker
  • Text fields, radio buttons, buttons, code, progress bar etc.
  • No dependencies which destroy you project when you distribute it. Just pure giant Rust binary

Full list of implemented features is available here

Install

Prebuilt binaries are provided for Linux and Windows. On other platforms pip will build wheel for your OS. In this case you'll need Rust compiler and maturin

Install from pypi

pip install pyegui

Install from source

git clone https://github.com/gachilord/pyegui
pip install <path to pyegui>

Usage

This is how you write a "hello world" app.

from pyegui import *

def update_func(ctx):
  # draw UI here
  heading("Hello, World!")

run_native("Example app", update_func)

You can find more examples in this folder. Also Python's help(pyegui.some_function) will be quite effective(there are examples for every function). Read the source code of this binding and the original library.

Update functions

pyegui has a notion of update functions which the library calls to draw your UI.

def update_func():
  # you can place here any widget
  heading("I'm a heading")
  # some widgets are interactive
  if button_clicked("I'm a clickable button"):
    # you can update state from here or show another widget
    print("Clicked")

The top level update function has the Context object that controls global aspects of your app(e.g fonts and theme).

def update_func(ctx):
  ctx.set_light_theme()
  heading("Using light theme even if system's is dark")

Update functions may be nested. Such functions create a new UI scope that can have different styles and befaviour.

def update_func(ctx):
  # define update_func
  def nested():
    label("I'm a label inside nested update function")
    label("New label")
    disable() # this function will disable all further widgets in the scope
    if button_clicked("You can't click me"):
      print("Unreachable")
  # all the widgets inside 'nested' will be centered vertically 
  horizontal_centered(nested)
  # this widget won't be disabled though it goes after 'disable()'
  if button_clicked("You can click me"):
    print("Clicked")

Variables

Many widgets require access to a state via a reference, which can't be done for integers, floats and strings in Python. That's why such helper classes as Str, Bool, Int, Float, RGB and Date exist.

They are essentially the following:

# Example for bool type
class Bool:
  value = False

These classes can be used to draw UI or to store user input. You have to create them outside of update functions.

data = Bool(False)

def update_func():
  heading(f"Value of the data is {data.value}")
  # button will be shown only if the checkbox is checked 
  if data.value and button_clicked("set to False"):
    # hiding the button
    data.value = False
  checkbox(data, "Check me")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyegui-0.3.1.tar.gz (116.1 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyegui-0.3.1-pp311-pypy311_pp73-win_amd64.whl (9.2 MB view details)

Uploaded PyPyWindows x86-64

pyegui-0.3.1-pp310-pypy310_pp73-win_amd64.whl (9.2 MB view details)

Uploaded PyPyWindows x86-64

pyegui-0.3.1-pp39-pypy39_pp73-win_amd64.whl (9.2 MB view details)

Uploaded PyPyWindows x86-64

pyegui-0.3.1-cp313-cp313t-win_amd64.whl (9.2 MB view details)

Uploaded CPython 3.13tWindows x86-64

pyegui-0.3.1-cp311-abi3-win_amd64.whl (9.2 MB view details)

Uploaded CPython 3.11+Windows x86-64

pyegui-0.3.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.9 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ x86-64

File details

Details for the file pyegui-0.3.1.tar.gz.

File metadata

  • Download URL: pyegui-0.3.1.tar.gz
  • Upload date:
  • Size: 116.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for pyegui-0.3.1.tar.gz
Algorithm Hash digest
SHA256 129103fb2f2ee12c17af095df52f8e22c629746181d321729453b4ae79bb2ee6
MD5 02003d266070f193dd0381d7d5601fd4
BLAKE2b-256 c3fc192dd389f191fc2484b2e1c1236b8052c95b0dc6f7952a00ea8723153f04

See more details on using hashes here.

File details

Details for the file pyegui-0.3.1-pp311-pypy311_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for pyegui-0.3.1-pp311-pypy311_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 a1629fcd4b8ee90aa3937be7e9d9bcacba7569a39dba24a87e1a8898cd474c01
MD5 70299f49a8db4b0017a23f7528f2cb2d
BLAKE2b-256 5ab6320dc415a24e2739d7983933a4725fabdeb151d8f03d6862b044c0ede9b2

See more details on using hashes here.

File details

Details for the file pyegui-0.3.1-pp310-pypy310_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for pyegui-0.3.1-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 dec1f0cc3e4b2b01635c9720ffae30140c1a64312672426007b1b081fdca47b3
MD5 2ff22d90861b5704786850090a310c96
BLAKE2b-256 21d8959c58f364eeff2f2854d7493bf3dc64ede40df2a896a6393b99390b8478

See more details on using hashes here.

File details

Details for the file pyegui-0.3.1-pp39-pypy39_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for pyegui-0.3.1-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 8bf25e638dba12434e092b8dae45cbeeb38b7fabfe47fd48d27d321dc149e76f
MD5 c9afc8b2c24582b67063d847833992d9
BLAKE2b-256 92acb260564a2b6114e1b7a024bb07be64c3fc666ef539c9612deb0d7ffa3fc9

See more details on using hashes here.

File details

Details for the file pyegui-0.3.1-cp313-cp313t-win_amd64.whl.

File metadata

  • Download URL: pyegui-0.3.1-cp313-cp313t-win_amd64.whl
  • Upload date:
  • Size: 9.2 MB
  • Tags: CPython 3.13t, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for pyegui-0.3.1-cp313-cp313t-win_amd64.whl
Algorithm Hash digest
SHA256 b0c77247bf44ed3be50f31900a0ef51d8ee735a3953157e8c49ea0db93ce8982
MD5 a09bdca07cd03966b7bd69ad53a6715a
BLAKE2b-256 39bf6753d932ee13c01fedf84b416c40866d2dc30b0bbe1eab73290e558dc248

See more details on using hashes here.

File details

Details for the file pyegui-0.3.1-cp311-abi3-win_amd64.whl.

File metadata

  • Download URL: pyegui-0.3.1-cp311-abi3-win_amd64.whl
  • Upload date:
  • Size: 9.2 MB
  • Tags: CPython 3.11+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for pyegui-0.3.1-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 b1bb5c8b401510f997fbadcc9200bbd03759fa45ee54e07c69a228d116fc10f5
MD5 6796406cd69ba60f8c062f3e376d1df4
BLAKE2b-256 bb28a247d3d6a8cbeba6e80f1041b0804d922b61e3041b7d7e8908ff3a550b90

See more details on using hashes here.

File details

Details for the file pyegui-0.3.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyegui-0.3.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dc2523861d3f1ecc3508ec5d81b877d85c3bd0d86cc9b99602b8b3242111ad37
MD5 a20ec875a8746f70450ecb6fbf8f16d7
BLAKE2b-256 9709f096a014f52a666a3b1fbf951536307462003a72c4cd563cdb9296ac8cc3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page