Skip to main content

A package for easily creating UIs in Python, mainly using OpenCV's drawing functions.

Project description

ImageUI

A package for easily creating UIs in Python, mainly using OpenCV's drawing functions.

Installation

pip install ImageUI

Usage

import SimpleWindow
import ImageUI
import numpy
import time

# Create a background to render the UI on
Background = numpy.zeros((250, 400, 3), dtype=numpy.uint8)
Background[:] = (28, 28, 28)

# Initialize a window could be a OpenCV window too
SimpleWindow.Initialize(Name="Example UI",
                        Size=(Background.shape[1], Background.shape[0]),
                        Position=(100, 100),
                        TitleBarColor=(28, 28, 28),
                        Resizable=False,
                        TopMost=False,
                        Foreground=True,
                        Minimized=False,
                        Undestroyable=False,
                        Icon="",
                        NoWarnings=False)

# Get all available translation languages
TranslationLanguages = list(ImageUI.Translations.GetAvailableLanguages().keys())

def SetTranslator(Language):
    # Set the auto UI translator, automatically translates all the UI elements
    ImageUI.SetTranslator(SourceLanguage="English", DestinationLanguage=Language)

def SetTheme(Theme):
    ThemeColor = (28, 28, 28) if Theme == "Dark" else (250, 250, 250)
    Background[:] = ThemeColor
    # Set the ImageUI theme, either "Dark" or "Light"
    ImageUI.SetTheme(Theme)
    SimpleWindow.SetTitleBarColor(Name="Example UI", Color=ThemeColor)

while True:
    # Add a button to the UI
    ImageUI.Button(Text="Button",
                   X1=10,
                   Y1=10,
                   X2=150,
                   Y2=45,
                   ID="Button",
                   OnPress=lambda: print("Button pressed!"))

    # Add a switch to the UI
    ImageUI.Switch(Text="Switch",
                   X1=10,
                   Y1=55,
                   X2=150,
                   Y2=80,
                   ID="Switch",
                   OnChange=lambda State: print("Switch changed to:", State))

    # Add a label to the UI
    ImageUI.Label(Text="This is a Label",
                  X1=200,
                  Y1=55,
                  X2=380,
                  Y2=80,
                  ID="Label")

    # Add a dropdown for language selection to the UI
    ImageUI.Dropdown(Title="Dropdown",
                     Items=TranslationLanguages,
                     DefaultItem="English",
                     X1=10,
                     Y1=90,
                     X2=190,
                     Y2=125,
                     ID="LanguageDropdown",
                     OnChange=SetTranslator)

    # Add a dropdown for theme selection to the UI
    ImageUI.Dropdown(Title="Theme",
                     Items=["Dark", "Light"],
                     DefaultItem="Dark",
                     X1=200,
                     Y1=90,
                     X2=380,
                     Y2=125,
                     ID="ThemeDropdown",
                     OnChange=SetTheme)

    # Add an input to the UI
    ImageUI.Input(X1=10,
                  Y1=135,
                  X2=380,
                  Y2=170,
                  Placeholder="Enter something...",
                  ID="Input",
                  OnChange=lambda Text: print("Input changed to:", Text))

    # Get the window handle
    WindowHandle = SimpleWindow.GetHandle(Name="Example UI")

    # Render the UI on the background
    Frame = ImageUI.Update(WindowHWND=WindowHandle, Frame=Background)

    # Show the background with the UI rendered on it
    SimpleWindow.Show(Name="Example UI", Frame=Frame)
    if SimpleWindow.GetOpen(Name="Example UI") != True:
        # Saves cache like translations
        ImageUI.Exit()
        break

    # Limit to about 60 FPS
    time.sleep(1 / 60)

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

imageui-0.41.tar.gz (54.0 kB view details)

Uploaded Source

Built Distribution

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

imageui-0.41-py3-none-any.whl (43.6 kB view details)

Uploaded Python 3

File details

Details for the file imageui-0.41.tar.gz.

File metadata

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

File hashes

Hashes for imageui-0.41.tar.gz
Algorithm Hash digest
SHA256 d3ca61a04cbc843e456d9549f6600b5efeafe7f57aa5da0b83fc14b2a3d902cc
MD5 ccee4803f6e2e926386c8d6fc03cfd9f
BLAKE2b-256 16c7b90ac5302af6f5447d73a82440fbe559b85e75033afeb68a2dc0f541d43d

See more details on using hashes here.

File details

Details for the file imageui-0.41-py3-none-any.whl.

File metadata

  • Download URL: imageui-0.41-py3-none-any.whl
  • Upload date:
  • Size: 43.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for imageui-0.41-py3-none-any.whl
Algorithm Hash digest
SHA256 fcf6d400cff3d2b96935137589d96ba0063b0a860c0c20fb86051fad16fc4657
MD5 22938f2a578c7d6ce90ebb3628218df3
BLAKE2b-256 abfa052a494aaf77fe37cc467abfc521ceebd73fdf9cd06c3d1770f8732fbd83

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