Skip to main content

A simple tool for building UIs

Project description

--DISCLAIMER-- the README below is deprecated. i am rebuilding the project from the ground up as the old project had bad architecture and was very slow.



\

dot-ui

An easy to use yet good-looking UI creation framework for Python

Contents

Basics

Creating a window

Opening a Window is as easy as creating a window object and calling open():

from dot_ui import *

win = Window()

win.open()

Opened Window

In the constructor you can specify the width, height, title, icon and whether the window should be opened in full screen mode.

Adding widgets

Adding a widget is no more compicated. You create the widget and add it to the window. It takes an x and y position as well as a width and height as optional constructor parameters:

from dot_ui import *

win = Window("Demo")

widget = Widget(10, 10)

win.add_widget(widget)

win.open()

Window with widget

Changing renderer settings

Some window and widget properties are universal and are controlled by the renderer. You can customize these settings by calling the corresponding setter on the renderer (DotRenderer by default):

from dot_ui import *

DotRenderer.set_corner_radius(0)
DotRenderer.set_shadow_offset(Vector2(-2, -2))
DotRenderer.set_shadow_radius(10)
DotRenderer.set_default_color(Color.GREEN)
DotRenderer.set_shadow_opacity(1)

win = Window(title="Demo")

widget = Widget(10, 10)

win.add_widget(widget)

win.open()

Changed renderer settings

Adding behaviours

You can add behaviours to widgets that consist of a function that is run on initialization and one that is run every tick. This is some example code that prints "Widget initialized" on initialization and prints the delta time every tick.

from dot_ui import *

win = Window(title="Demo")

def print_init(self: Widget):
    print("Widget initialized")

def print_on_tick(self: Widget, delta):
    print(delta)

widget = Widget(10, 10)

widget.add_behaviour("Print", print_on_tick, print_init)

win.add_widget(widget)

win.open()

Taking inputs

The Input class allows you to create actions that are triggered when one of multiple keys or key combinations is pressed. You can then check if these actions have been triggered. This code will print the delta time when "D" or "0" are pressed and close the widget when Crtl+Q is pressed.

from dot_ui import *

Input.add_action("Print Delta", Key.D, 0)

Input.add_action(
    "Close", 
    KeyCombination(Key.L_CTRL, Key.Q)
)

win = Window(title="Demo")


def input_demo(self: Widget, delta):
    if Input.action_pressed("Print Delta"):
        print(delta)
    
    if Input.action_just_pressed("Close"):
        self.close()


widget = Widget(10, 10)

widget.add_behaviour("Input Demo", input_demo)

win.add_widget(widget)

win.open()

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

widgeon-0.0.2.tar.gz (122.5 kB view details)

Uploaded Source

Built Distribution

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

widgeon-0.0.2-py3-none-any.whl (119.7 kB view details)

Uploaded Python 3

File details

Details for the file widgeon-0.0.2.tar.gz.

File metadata

  • Download URL: widgeon-0.0.2.tar.gz
  • Upload date:
  • Size: 122.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.10

File hashes

Hashes for widgeon-0.0.2.tar.gz
Algorithm Hash digest
SHA256 a7920f2c44e4dab3e6f03baed60ef980919962825715e20118427c9ae58ceaed
MD5 c1d272eb00ed4686d6332e45934460fe
BLAKE2b-256 3c597a852aa73cf6420cc5d8796c2acf397b13ea4759a01ed6414937e9a2d0bc

See more details on using hashes here.

File details

Details for the file widgeon-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: widgeon-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 119.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.10

File hashes

Hashes for widgeon-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2027160a7d983a5f9b9b1f117a8984537201bb5aa38754560ae7add1f0c6b8b3
MD5 b109cd6a4df5057aee733a3d8e29a887
BLAKE2b-256 0e548859936b9d255c0c7a0b5382548f606a4907bc0af2c3996c6aebf0c7175a

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