Skip to main content

Every game needs a user interface that matches its look and feel. The purpose of glooey is to help you make such an interface. Towards this end, glooey provides 7 powerful placement widgets, a label widget, an image widget, 3 different button widgets, a text entry widget, a variety of scroll boxes and bars, 4 different dialog box widgets, and a variety of other miscellaneous widgets. The appearance of any widget can be trivially customized, and glooey comes with built-in fantasy, puzzle, and 8-bit themes to prove it (and to help you hit the ground running if your game fits one of those genres).

The philosophy behind glooey is that deriving subclasses from a basic set of widgets with no default style is the most elegant way to control how widgets look. This approach is flexible because subclasses can customize or override most aspects of the basic widgets. But it’s also surprisingly succinct and powerful: specifying a style is usually as simple as setting a class variable, and styles can be easily composed using either inner classes or previously defined widgets. This philosophy makes glooey easy to get started with, and powerful enough to support even the most complicated games.

https://img.shields.io/pypi/v/glooey.svg https://img.shields.io/pypi/pyversions/glooey.svg https://img.shields.io/github/workflow/status/kxgames/glooey/Test%20and%20release/master https://img.shields.io/readthedocs/glooey.svg

A quick example

The documentation thoroughly explains what glooey can do and how to use it, but here’s a quick example to give a feel for what it looks like in action:

$ pip3 install glooey
#!/usr/bin/env python3

import pyglet
import glooey

# Define a custom style for text.  We'll inherit the ability to render text
# from the Label widget provided by glooey, and we'll define some class
# variables to customize the text style.

class MyLabel(glooey.Label):
    custom_color = '#babdb6'
    custom_font_size = 10
    custom_alignment = 'center'

# If we want another kind of text, for example a bigger font for section
# titles, we just have to derive another class:

class MyTitle(glooey.Label):
    custom_color = '#eeeeec'
    custom_font_size = 12
    custom_alignment = 'center'
    custom_bold = True

# It's also common to style a widget with existing widgets or with new
# widgets made just for that purpose.  The button widget is a good example.
# You can give it a Foreground subclass (like MyLabel from above) to tell it
# how to style text, and Background subclasses to tell it how to style the
# different mouse rollover states:

class MyButton(glooey.Button):
    Foreground = MyLabel
    custom_alignment = 'fill'

    # More often you'd specify images for the different rollover states, but
    # we're just using colors here so you won't have to download any files
    # if you want to run this code.

    class Base(glooey.Background):
        custom_color = '#204a87'

    class Over(glooey.Background):
        custom_color = '#3465a4'

    class Down(glooey.Background):
        custom_color = '#729fcff'

    # Beyond just setting class variables in our widget subclasses, we can
    # also implement new functionality.  Here we just print a programmed
    # response when the button is clicked.

    def __init__(self, text, response):
        super().__init__(text)
        self.response = response

    def on_click(self, widget):
        print(self.response)

# Use pyglet to create a window as usual.

window = pyglet.window.Window()

# Create a Gui object, which will manage the whole widget hierarchy and
# interact with pyglet to handle events.

gui = glooey.Gui(window)

# Create a VBox container, which will arrange any widgets we give it into a
# vertical column.  Center-align it, otherwise the column will take up the
# full height of the window and put too much space between our widgets.

vbox = glooey.VBox()
vbox.alignment = 'center'

# Create a widget to pose a question to the user using the "title" text
# style,  then add it to the top of the vbox.

title = MyTitle("What...is your favorite color?")
vbox.add(title)

# Create several buttons with different answers to the above question, then
# add each one to the vbox in turn.

buttons = [
       MyButton("Blue.", "Right, off you go."),
       MyButton("Blue. No yel--", "Auuuuuuuugh!"),
       MyButton("I don't know that!", "Auuuuuuuugh!"),
]
for button in buttons:
   vbox.add(button)

# Finally, add the vbox to the GUI.  It's always best to make this the last
# step, because once a widget is attached to the GUI, updating it or any of
# its children becomes much more expensive.

gui.add(vbox)

# Run pyglet's event loop as usual.

pyglet.app.run()

Metadata

Release files for glooey 0.3.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for glooey 0.3.6
File Size Uploaded
glooey-0.3.6.tar.gz 19.1 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for glooey 0.3.6
File Interpreter ABI Platform
glooey-0.3.6-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 29.9 MB

Release files / glooey-0.3.6.tar.gz

Download URL glooey-0.3.6.tar.gz
Size 19.1 MB
Tags Source
SHA-256 checksum
How to use checksums
c025aca6c0e8d73f99793cb7b15aa547195da5499a11384379f2d3446f864520
BLAKE2b-256 checksum
How to use checksums
f55fa4ba0e3a27dd111ecf8ed8904d48d367cafbb2550b23ecdb3170479025e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.12

Release files / glooey-0.3.6-py2.py3-none-any.whl

Download URL glooey-0.3.6-py2.py3-none-any.whl
Size 10.8 MB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
ad4574428ec2bfb3c1e18f0eee1c927c3d4f95a3f4fec57dc8dd069cda33aa61
BLAKE2b-256 checksum
How to use checksums
8955c6bb75bf3e0a652199dd103c313e9064e22566960880503a84eb9f4dbe16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.12

Release history Release notifications | RSS feed

This release

0.3.6 This release

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page