first version of PythonSignals - need to be finalized a bit, but work basically
[vuplus_dvbapp] / mytest.py
1 from enigma import *
2
3 import sys
4 import time
5
6 from screens import *
7 from skin import applyGUIskin
8
9 # A screen is a function which instanciates all components of a screen into a temporary component.
10 # Thus, the global stuff is a screen, too.
11 # In a screen, components can either be instanciated from the class-tree, cloned (copied) or
12 # "linked" from the instance tree.
13 # A screen itself lives as the container of the components, so a screen is a component, too.
14
15 # we thus have one (static) hierarchy of screens (classes, not instances)
16 # and one with the instanciated components itself (both global and dynamic)
17
18 def dump(dir, p = ""):
19         if isinstance(dir, dict):
20                 for (entry, val) in dir.items():
21                         dump(val, p + "/" + entry)
22         print p + ":" + str(dir.__class__)
23
24 # defined components
25 components = {}
26
27 # do global
28 screens["global"](components)
29
30 # test our screens
31 components["$001"] = screens["testDialog"]()
32 components["$002"] = screens["clockDisplay"](components["clock"])
33
34 print "*** classes:"
35 dump(screens)
36
37 print "*** instances:"
38 dump(components)
39
40 # display
41
42 class OutputDevice:
43         def create(self, screen): pass
44
45 # display: HTML
46
47 class HTMLOutputDevice(OutputDevice):
48         def create(self, comp):
49                 print comp.produceHTML()
50
51 html = HTMLOutputDevice()
52
53 class GUIOutputDevice(OutputDevice):
54         parent = None
55         def create(self, comp):
56                 comp.createGUIScreen(self.parent)
57
58
59
60 def test():
61         desktop = getDesktop()
62         print "desktop: " + str(desktop)
63
64         wnd = eWindow(desktop)
65         print "window " + str(wnd)
66         wnd.setTitle("python")
67         wnd.move(ePoint(300, 100))
68         wnd.resize(eSize(300, 300))
69
70         gui = GUIOutputDevice()
71         gui.parent = wnd
72         gui.create(components["$002"])
73 #       for (x,y) in components["$001"].data.items():
74 #               print str(x) + " -> " + str(y) + " (" + y["instance"].getText() + ")"
75
76 #       print components["$001"].data["okbutton"]["instance"].doClick()
77
78 # diese sachen gehoeren in den skin! :)
79         applyGUIskin(components["$002"], None, "clockDialog")
80         
81 # das ist dann schon die echte funktionalitaet ;)
82         components["clock"].doClock()
83         components["clock"].doClock()
84
85
86 # output as html
87         print "--------------------------------------"
88         html.create(components["$001"])
89         print "--------------------------------------"
90         html.create(components["$002"])
91         print "--------------------------------------"
92         
93         
94 # direkter test der GUI aus python:
95 #       label1 = eLabel(wnd)
96 #       label1.setText("hello world!\nfrom python!")
97 #       label1.move(ePoint(10, 10))
98 #       label1.resize(eSize(80, 50))
99 #
100 #       label2 = eLabel(wnd)
101 #       label2.setText("the second\nlabel works\nas well!")
102 #       label2.move(ePoint(90, 10))
103 #       label2.resize(eSize(80, 50))
104 #
105 #       button = eButton(wnd)
106 #       button.setText("OK")
107 #       button.move(ePoint(200, 10))
108 #       button.resize(eSize(80, 50)) 
109
110         wnd.show()
111
112         for x in range(200):
113                 time.sleep(0.1)
114                 components["clock"].doClock()
115                 if x > 100:
116                         r = 200 - x
117                 else:
118                         r = x
119                 components["$002"]["okbutton"].setValue(r)
120                 desktop.paint()
121         
122 #       
123 #       print "delete label1"
124 #       del button
125 #       del label2
126 #       del label1
127 #       print "delete wnd"
128 #       del wnd
129 #       print "bye"
130
131         
132         
133         return 0