| name | pythonide-scene |
|---|---|
| description | Build or repair PythonIDE 2D scene scripts, SpriteKit-style games, touch demos, physics samples, and turtle graphics using scene.run or turtle. Use when the user wants continuous drawing, sprites, collisions, frame loops, or game-style interaction — not AppUI forms or widgets. |
| license | MIT |
| version | 1.0.0 |
| last_updated | 2026-06-10 |
| user_invocable | true |
Execution rulebook for scene and turtle runtimes.
- Scene module
- Scene API reference
- scene.pyi
- Turtle module for teaching graphics
Do not generate AppUI or widget code for a scene/game request.
- Continuous drawing, sprite movement, collisions, physics, touch loops, or shaders
- Existing code imports
sceneand needs repair - Turtle teaching demos
- The UI is a form, list, settings screen, or AppUI MiniApp
- The user wants imperative UIKit controls →
pythonide-automation(ui) - Static charts or business apps →
pythonide-appui
- Subclass
scene.Scene - Create retained nodes in
setup()afterself.sizeis valid - Per-frame logic in
update(); immediate drawing only indraw() - Touch in
touch_began/touch_moved/touch_ended - End with exactly one
scene.run(MyScene(), ...) - Keep assets optional unless the user provides them
import scene
class Demo(scene.Scene):
def setup(self):
self.background_color = "#111827"
self.ball = scene.SpriteNode(
color="#2f80ed",
size=(44, 44),
position=(self.size.w / 2, self.size.h / 2),
parent=self,
)
self.label = scene.LabelNode(
"Tap to move",
font=("Helvetica", 18),
position=(self.size.w / 2, 80),
parent=self,
)
def touch_began(self, touch):
self.ball.run_action(
scene.Action.move_to(touch.location.x, touch.location.y, 0.25)
)
self.label.text = f"{touch.location.x:.0f}, {touch.location.y:.0f}"
scene.run(Demo(), show_fps=True)- No AppUI (
Button,VStack,NavigationStack, etc.) inside aScene - No blocking
while Trueanimation loops; useupdate()orAction - No
rect,fill,text, etc. outsidedraw() SpriteNode("red")treats"red"as a texture name — useSpriteNode(color="red", ...)- Do not omit
scene.run(...) image_quad/triangle_stripare not implemented
- Use physics bodies only when collisions matter
- Retain sprites, labels, and game state on
self - Use
node.run_action(...)for motion; callingAction.move_to(...)alone does nothing
- Use
import turtleonly for teaching/simple vector drawing - Do not mix turtle and scene in one deliverable unless repairing existing code
| Issue | Fix |
|---|---|
| Blank scene | verify scene.run(...) and setup() does not crash |
| Node at origin | set explicit position from self.size |
| No motion | node.run_action(...), not bare Action |
| Dead touch | implement touch_began(self, touch) |
examples/tap_ball/— tap-to-move sprite demo