Sharedwww / talks / 2006-05-09-sage-digipen / tutorial / pudding-console-2.pyOpen in CoCalc
Author: William A. Stein
1
#!/usr/bin/env python
2
3
""" a complete python console in soya """
4
5
import sys, os
6
7
8
import soya
9
import soya.pudding as pudding
10
import soya.pudding.python_console
11
12
soya.init(width = 800, height = 600)
13
soya.path.append(os.path.join(os.path.dirname(sys.argv[0]), "data"))
14
15
# initialise pudding
16
pudding.init()
17
18
pudding.STYLE.background_color = (.2, .2, .2, .4 )
19
20
scene = soya.World()
21
22
camera = soya.Camera(scene)
23
24
root = pudding.core.RootWidget(width = 640, height = 480)
25
soya.set_root_widget(root)
26
27
panel = pudding.control.Panel(root, left = 10, top = 10, label = "console")
28
panel.right = 10
29
panel.bottom = 380
30
panel.anchors = pudding.ANCHOR_ALL
31
32
console = pudding.python_console.PythonConsole(panel, left=10, top=30, lokals = locals())
33
console.right=10
34
console.bottom=10
35
console.anchors = pudding.ANCHOR_ALL
36
console.input.border_width = 0
37
38
root.add_child(camera)
39
40
# we need to do this to force the layout to refresh
41
root.on_resize()
42
43
44
class Idler(soya.Idler):
45
def begin_round(self):
46
soya.Idler.begin_round(self)
47
48
pudding.process_event()
49
50
pudding.idler.Idler(scene).idle()
51
52