August'24: Kamaelia is in maintenance mode and will recieve periodic updates, about twice a year, primarily targeted around Python 3 and ecosystem compatibility. PRs are always welcome. Latest Release: 1.14.32 (2024/3/24)
Cookbook Example
How can I...?
Example 8: Simple pygame based presentation tool. Components used:Graphline, Button, Chooser, Image
#!/usr/bin/python
from Kamaelia.UI.Pygame.Button import Button
from Kamaelia.UI.Pygame.Image import Image
from Kamaelia.Util.Chooser import Chooser
from Kamaelia.Util.Graphline import Graphline
import os
= "Slides"
path = ".gif"
extn = os.listdir(path)
allfiles = list()
files for fname in allfiles:
if fname[-len(extn):]==extn:
files.append(os.path.join(path,fname))
files.sort()
Graphline(= Chooser(items = files),
CHOOSER = Image(size=(800,600), position=(8,48)),
IMAGE = Button(caption="Next", msg="NEXT", position=(72,8)),
NEXT = Button(caption="Previous", msg="PREV",position=(8,8)),
PREVIOUS = Button(caption="First", msg="FIRST",position=(256,8)),
FIRST = Button(caption="Last", msg="LAST",position=(320,8)),
LAST = {
linkages "NEXT","outbox") : ("CHOOSER","inbox"),
("PREVIOUS","outbox") : ("CHOOSER","inbox"),
("FIRST","outbox") : ("CHOOSER","inbox"),
("LAST","outbox") : ("CHOOSER","inbox"),
("CHOOSER","outbox") : ("IMAGE","inbox"),
(
} ).run()
Source: Examples/example8/slideshow.py