ApkPy 1.15.0¶
Released 2026-11-14. python -m pip install --upgrade apkpy==1.15.0.
An app can have a game, written in Python and made with a Studio. Boxes take
gradients, see-through colours and shadows with a colour, and a tap puts on a
state the stylesheet names. A field says which keyboard it wants. The app
reaches more of the phone: reminders at a time, alarms, calls, the calendar,
the gallery and the clipboard. The phone runs more of Python: sets,
Counter, defaultdict, functions kept as values.
from apkpy_lib import *
quiz = Screen(id="quiz")
label("Tea or coffee?", id="question", screen=quiz)
def pick_tea():
tea.set_state("selected")
coffee.set_state(None)
def pick_coffee():
coffee.set_state("selected")
tea.set_state(None)
tea = container(id="answer", on_click=pick_tea, screen=quiz)
label("Tea", id="answer_text", parent=tea)
coffee = container(id="answer", on_click=pick_coffee, screen=quiz)
label("Coffee", id="answer_text", parent=coffee)
style = """
quiz {
background: linear-gradient(160deg, #1E1B4B, #0F172A);
padding: 24px;
}
question {
color: #FFFFFF;
font-size: 22px;
}
answer {
margin-top: 12px;
padding: 16px;
border-radius: 16px;
border-width: 1px;
border-color: #FFFFFF33;
background-color: rgba(255, 255, 255, 0.08);
}
answer:selected {
background: linear-gradient(90deg, #7C5CFF, #B06CFF);
box-shadow: 0 8px 24px rgba(124, 92, 255, 0.55);
}
answer_text {
color: #FFFFFF;
}
"""
run(start_screen=quiz)
The answer you tap lights up with a gradient and a violet glow, on the phone and in the Previewer, and the other goes back to glass.
Games¶
apkpy start Hopper --game platformer makes an app with a game: 2D, or 2.5D in
the style of the DS-era RPGs, written in Python in game/ and run by a Java
engine that is the same on the phone and on the PC. Twelve templates start
one -- a platformer, a shooter, a runner, bricks, a top-down adventure, a tap
game, a puzzle, a 2.5D world, a monster-catching RPG, a game with menus, a
tutorial and a blank one -- each a whole short game with its art and sounds.
apkpy game studio opens the Studio: one window to change the objects, the
scenes and their rules, the levels, the sounds and the pictures, and to play
the game inside it. It writes the game's own Python, only what changed, so
the code stays yours. enable_game() gives the app game_play() and the
rest. The engine was written by RĂºben Rego as ApkPyGame and is part of ApkPy
from this version. See Your first game.
Gradients, see-through colours and shadows¶
background: linear-gradient(...) and radial-gradient(...), several layers
on one box, rgba() and hsl(), opacity on any component, a
box-shadow with a colour and shimmer, the band of light on a progress
bar. A hex with alpha puts it last, as CSS does (see Changed).
See Themes and styling.
A box you tap, dialogs and a floating bar¶
container() and card() take on_click=, and set_state("selected") puts
on the look of answer:selected { ... }. A dialog { ... } block draws
alert() and confirm() as a card of the app, and ok= and cancel= choose
the words of their buttons. A bottom_nav with a margin and corners floats
over the content. See Components.
The keyboard, a draw pad and a web page¶
inputs(type="email"), "phone" and "url" open the keyboard for each;
action="send" and on_submit= say what the key in the keyboard's corner
does, and autofill= tells password managers what the field is.
hide_keyboard() and field.focus() close and open it. draw_pad() is a box
to sign in with a finger, kept as a PNG. web_page(html=...) shows HTML
inside the screen, and a fenced code block in markdown() is coloured by its
language. See The keyboard and
Draw pad.
More of the phone¶
notify(..., at="09:00") posts a reminder at a time, with the app closed;
clock.alarm() and clock.timer() set them in the phone's clock;
phone.call() places a call; calendar.events() reads the calendar;
gallery.save() puts a picture in the gallery; clipboard.paste() reads
what was copied; display.on_screenshot() says when the screen was captured.
See Phone actions and
Notifications.
More of Python¶
Sets, Counter and defaultdict from collections, functions kept in names
and lists, bitwise operators, positional-only and keyword-only parameters,
and arithmetic on items of a list or a dict and on a parameter -- with
Python's answers and Python's TypeError where Python stops. What the top of
the file works out from constants is worked out at build. See
Python compatibility.
Changed¶
- A hex colour with alpha puts it last, as CSS writes it.
#00000080is black at half strength, as in every browser. It used to be read in Android's order, alpha first, so#00000080was a box you could not see. A stylesheet written in Android's order (#80000000) now reads as a colour that is almost transparent; the build says so withU2049and gives the colour to write instead. - CSS colour names mean what they mean in CSS, on the phone too:
greenis#008000, and all 148 names reach the phone. - A screen's Java holds only what that screen uses. A four-screen app had 10,600 lines of screen Java, nine in ten never run; it now has 1,215.
- The compiler is a folder,
apkpy_lib/core/compiler/, for who reads ApkPy's own code.from apkpy_lib.core.compiler import translate_python_to_androidis the same line as before.
Same on the phone and in the Previewer¶
- A label's own
paddingreplaces the indent it has in a card or a screen. - A list or a dict read out of another one shows as Python shows it:
['tea'], not the JSON["tea"]. - A field low on a scrolling screen stays above the keyboard on Android 15 and later.
- A flex row lays out what is in it the way CSS does, a chart is as wide as
its
width, and a button wears its stylesheet's padding. - Python 3.14 translates apps again: it had removed
ast.Strandast.Num. apkpy run --releasemakes an APK that installs.
Every change, with the details, is in the changelog.