8 from skin import applyGUIskin
10 # A screen is a function which instanciates all components of a screen into a temporary component.
11 # Thus, the global stuff is a screen, too.
12 # In a screen, components can either be instanciated from the class-tree, cloned (copied) or
13 # "linked" from the instance tree.
14 # A screen itself lives as the container of the components, so a screen is a component, too.
16 # we thus have one (static) hierarchy of screens (classes, not instances)
17 # and one with the instanciated components itself (both global and dynamic)
19 def dump(dir, p = ""):
20 if isinstance(dir, dict):
21 for (entry, val) in dir.items():
22 dump(val, p + "/" + entry)
23 print p + ":" + str(dir.__class__)
34 def create(self, screen): pass
38 class HTMLOutputDevice(OutputDevice):
39 def create(self, comp):
40 print comp.produceHTML()
42 html = HTMLOutputDevice()
44 class GUIOutputDevice(OutputDevice):
46 def create(self, comp):
47 comp.createGUIScreen(self.parent)
52 self.delayTimer = eTimer()
53 self.delayTimer.timeout.get().append(self.processDelay)
55 self.currentDialog = None
57 self.dialogStack = [ ]
59 def processDelay(self):
60 self.currentDialog.doClose()
61 if self.currentWindow != None:
62 self.currentWindow.hide()
64 del self.currentDialog
65 del self.currentWindow
67 if len(self.dialogStack):
68 (self.currentDialog, self.currentWindow) = self.dialogStack.pop()
69 self.currentWindow.show()
71 def open(self, screen):
72 if self.currentDialog:
73 self.dialogStack.append((self.currentDialog, self.currentWindow))
74 self.currentWindow.hide()
76 self.currentDialog = screen
79 if self.desktop != None:
80 self.currentWindow = wnd = eWindow(self.desktop)
81 # wnd.setTitle("Screen from python!")
82 # wnd.move(ePoint(300, 100))
83 # wnd.resize(eSize(300, 300))
85 gui = GUIOutputDevice()
87 gui.create(self.currentDialog)
89 applyGUIskin(self.currentDialog, wnd, None, screen.__class__.__name__)
93 self.currentWindow = None
95 def keyEvent(self, code):
96 # print "code " + str(code)
98 self.currentDialog["okbutton"].instance.push()
101 self.currentDialog["channelSwitcher"].instance.push()
103 if code >= 0x30 and code <= 0x39:
105 self.currentDialog["menu"].instance.moveSelection(code - 0x31)
107 self.currentDialog["list"].instance.moveSelection(code - 0x31)
110 self.delayTimer.start(0, 1)
114 session.desktop = getDesktop()
116 session.nav = pNavigation()
118 session.open(infoBar())
120 CONNECT(keyPressedSignal(), session.keyEvent)
127 # first, setup a screen
130 # now, run the mainloop