Metadata-Version: 2.4
Name: kodeskriver
Version: 0.2.1
Summary: A beginner-friendly Python library for graphics, animation and games
Author: Hopen Utvikling
License-Expression: MIT
Project-URL: Homepage, https://undervisning.net/andre_ressurser/kodeskriver.html
Project-URL: Documentation, https://undervisning.net/andre_ressurser/kodeskriver.html
Keywords: python,education,programming,coding,school,graphics,turtle,games
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Education
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: images
Requires-Dist: Pillow>=10; extra == "images"
Dynamic: license-file

# Kodeskriver

**Kodeskriver** is a beginner-friendly Python library for learning programming through real Python code, graphics, animation and simple games.

The public programming API is intentionally **English**, matching normal Python programming vocabulary. The Kodeskriver app can localize titles and help text, but the Python code itself remains English.

## Installation

```bash
pip install kodeskriver
```

Kodeskriver requires Python 3.10 or newer.

## First program

```python
from kodeskriver import *

write_text("Hello from Kodeskriver!", 0, 100, 28, "#46f0f0")

player = sprite(x=0, y=0, name="Player")
player.set_size_px(60, 60)

on_key_press("right", lambda: player.change_x(20))
on_key_press("left", lambda: player.change_x(-20))
on_key_press("up", lambda: player.change_y(20))
on_key_press("down", lambda: player.change_y(-20))
```

## A small game

```python
from kodeskriver import *

player = sprite(x=0, y=0, name="Player")
coin = sprite(x=150, y=80, name="Coin")
score = 0

player.control_with_arrow_keys(6)


def update():
    global score

    if player.touching(coin):
        score += 1
        coin.go_to_random_position()
        show_variable("Score", score)


every_frame(update)
```

## Sprites

```python
player = sprite("player.png", x=0, y=0, name="Player")

player.move(20)
player.go_to(100, 50)
player.change_x(10)
player.change_y(10)
player.point_in_direction(90)
player.turn_right(15)
player.turn_left(15)
player.bounce_on_edge()
player.set_size(120)
player.set_size_px(80, 80)
player.show()
player.hide()
```

Sprites have stable internal IDs, so multiple sprites may use the same visible `name` without overwriting one another.

## Keyboard and events

```python
on_key_press("space", function)
on_key_press("right", function)
on_screen_tap(function)
every_frame(function)
every_n_seconds(1, function)
```

## Text, variables and random numbers

```python
write_text("Hello", 0, 0, 24, "#ffffff")
clear_text()
show_variable("Score", 10)
hide_variable("Score")

dice = random_number(1, 6)
```

## Images

PNG and GIF files work directly when supported by Python/Tk. JPG and improved image scaling are available when Pillow is installed:

```bash
pip install "kodeskriver[images]"
```

## Backends

Kodeskriver automatically selects a backend:

- **Inside the Kodeskriver app / Pyodide:** uses the app's KSGame graphics engine.
- **Regular CPython on Windows, macOS and Linux:** uses the included desktop backend.

You can inspect the selected backend with:

```python
from kodeskriver import backend_name
print(backend_name())
```

On Homebrew Python for macOS, tkinter may need to be installed separately, for example:

```bash
brew install python-tk@3.12
```

Use the matching `python-tk` formula for your installed Python version.

## Turtle

You can also use Python's standard turtle module through:

```python
from kodeskriver.turtle import *
```

## Status

Version **0.2.1** is an alpha release. It introduces the English public API used by the current Kodeskriver app. It intentionally replaces the experimental Norwegian API used in the earlier TestPyPI prototype.

## License

Kodeskriver is released under the **MIT License**.

Copyright © 2026 Hopen Utvikling
