Beta Widgets


The following widgets are in beta - they're available and being used, they're just not quite finished...

MicroBit Emulator


Widget to emulate a MicroBit

MicroBit Emulator

from appJar import gui

app = gui()
app.addMicroBit("mb1")
app.setMicroBitImage("mb1", "09090:90909:90009:09090:00900")
app.go()

Add MicroBits

Set MicroBits

GoogleMaps


A self-contained GoogleMaps widget.
It provides useful functionality for finding somewhere on Earth.
All requests for map data are performed in the background, so the UI shouldn't become unresponsive.

GoogleMaps

from appjar import gui

app = gui()
app.addGoogleMap("m1")
app.setGoogleMapSize("m1", "300x500")
app.go()

Add GoogleMaps

Set GoogleMaps

Get GoogleMaps

Save GoogleMaps

PieChart


Widget to depict a Pie Chart.
It will automatically calculate percentages, and draw a pie chart, given a dictionary of items and their amount.
The PieChart is purely for display purposes, and is not interactive, other than a simple mouse-over effect with a tooltip.
PieChart

from appJar import gui

app = gui()
app.addPieChart("p1", {"apples":50, "oranges":200, "grapes":75,
                        "beef":300, "turkey":150})
app.go()

Add PieCharts

Set PieCharts

Tree


Takes an arbitrary XML string, and converts it into a tree structure.

TreeWidget

from appJar import gui

app = gui()
app.addTree("t1",
            """<people>
            <person><name>Fred</name><age>45</age><gender>Male</gender></person>
            <person><name>Tina</name><age>37</age><gender>Female</gender></person>
            <person><name>CLive</name><age>28</age><gender>Male</gender></person>
            <person><name>Betty</name><age>51</age><gender>Female</gender></person>
            </people>""")
app.go()

Add Trees

Set Trees

Get Trees


Advertisement why?


Grid


Used to create a spreadsheet like interface.
The grid has mouse interactivity, with mouse-over highlighting, and mouse-click highlighting.
It is possible to include buttons at the end of each row, and an additional row of entry boxes, with their own button.

Grid

from appJar import gui

app = gui()
app.setFont(20)
app.addGrid("g1",
    [["Name", "Age", "Gender"],
    ["Fred", 45, "Male"],
    ["Tina", 37, "Female"],
    ["Clive", 28, "Male"],
    ["Betty", 51, "Female"]])
app.go()

Add Grids

Connecting to Databases

Get Grids

Set Grids

To have the Press button on the entries row add a new row of data, try the following:

    def press(btn):
        if btn == "addRow":     # the button on the entries row
            data = app.getGridEntries("g1")
            app.addGridRow("g1", data)

MatPlotLib


Support for embedding very basic MatPlotLib plots.

Plot

from numpy import sin, pi, arange
from appJar import gui 
import random

def getXY():
    x = arange(0.0, 3.0, 0.01)
    y = sin(random.randint(1,10) * pi * x)
    return x,y 

def generate(btn):
    # *getXY() will unpack the two return values
    # and pass them as separate parameters
    app.updatePlot("p1", *getXY())
    showLabels()

def showLabels():
    axes.legend(['The curve'])
    axes.set_xlabel("X Axes")
    axes.set_ylabel("Y Axes")
    app.refreshPlot("p1")

app = gui()
axes = app.addPlot("p1", *getXY())
showLabels()
app.addButton("Generate", generate)
app.go()
from appJar import gui 
from mpl_toolkits.mplot3d import Axes3D

with gui() as app:
    fig = app.addPlotFig("p1")
    ax = fig.add_subplot(111, projection='3d')
    ax.scatter([1,2],[1,2],[1,2])

Advertisement why?


Canvas


This lets you embed a canvas in appJar

Canvas

from appJar import gui
app=gui()
canvas = app.addCanvas("c1")
canvas.create_oval(10, 10, 100, 100, fill="red", outline="blue", width=3)
canvas.create_line(0, 0, 255, 255, width=5)
canvas.create_line(0, 255, 255, 0, dash=123)
app.go()

Drawing on a Canvas

Turtle


This lets you embed a turtle widget in appJar.

Turtle

from appJar import gui 

def press(b):
    s = app.getTurtleScreen("t1")
    t = app.getTurtle("t1")
    s.bgcolor("blue")
    t.pencolor("white")
    for i in range(20):
        t.forward(i * 10) 
        t.right(144)

app=gui()
app.addTurtle("t1")
app.addButton("DRAW", press)
app.go()