appJar

The easiest way to create GUIs in Python.


Written by a teacher, in the classroom, for students.

appJar is designed to run on as many versions of Python as possible - so it should work in your school.

There are no other dependencies - simply download, unzip, and put it in your code folder.
Check out the installation instructions for other ways to get appJar working.

GUIs in Python are hard, there's a huge amount of boilerplate code required to get things working - so we hide all of that.
We're also not big fans of lots of parameters, so we keep them to a minimum, instead giving functions to get & set most things.

Hello appJar


GUIs in appJar require three steps.

# import the library
from appJar import gui
# create a GUI variable called app
app = gui()
# add & configure widgets - widgets get a name, to help referencing them later
app.addLabel("title", "Welcome to appJar")
app.setLabelBg("title", "red")
# start the GUI
app.go()

Interactivity


Of course, the whole point of making a GUI, is to be interactive - this requires events.

The idea behind event-driven programming is that each time the user clicks, presses or drags something (an event) the GUI should respond.

app.addLabelEntry("Username")
app.addLabelSecretEntry("Password")
def press(button):
    if button == "Cancel":
        app.stop()
    else:
        usr = app.getEntry("Username")
        pwd = app.getEntry("Password")
        print("User:", usr, "Pass:", pwd)
# link the buttons to the function called press
app.addButtons(["Submit", "Cancel"], press)

When the user presses a button, the press function is called, passing the name of the button as a parameter.

Appearance counts


As well as changing widgets, you can also change the way the GUI looks:

app = gui("Login Window", "400x200")
app.setBg("orange")
app.setFont(18)
app.setFocus("Username")

Make your own


And, that's all you need to know. Check out:

Full code-listing


Below is the full code-listing created on this page:

# import the library
from appJar import gui

# handle button events
def press(button):
    if button == "Cancel":
        app.stop()
    else:
        usr = app.getEntry("Username")
        pwd = app.getEntry("Password")
        print("User:", usr, "Pass:", pwd)

# create a GUI variable called app
app = gui("Login Window", "400x200")
app.setBg("orange")
app.setFont(18)

# add & configure widgets - widgets get a name, to help referencing them later
app.addLabel("title", "Welcome to appJar")
app.setLabelBg("title", "blue")
app.setLabelFg("title", "orange")

app.addLabelEntry("Username")
app.addLabelSecretEntry("Password")

# link the buttons to the function called press
app.addButtons(["Submit", "Cancel"], press)

app.setFocus("Username")

# start the GUI
app.go()