7 from skin import applyGUIskin
10 def CONNECT(slot, fnc):
11 slot.get().append(fnc)
13 def DISCONNECT(slot, fnc):
14 slot.get().remove(fnc)
16 # A screen is a function which instanciates all components of a screen into a temporary component.
17 # Thus, the global stuff is a screen, too.
18 # In a screen, components can either be instanciated from the class-tree, cloned (copied) or
19 # "linked" from the instance tree.
20 # A screen itself lives as the container of the components, so a screen is a component, too.
22 # we thus have one (static) hierarchy of screens (classes, not instances)
23 # and one with the instanciated components itself (both global and dynamic)
25 def dump(dir, p = ""):
26 if isinstance(dir, dict):
27 for (entry, val) in dir.items():
28 dump(val, p + "/" + entry)
29 print p + ":" + str(dir.__class__)
40 def create(self, screen): pass
44 class HTMLOutputDevice(OutputDevice):
45 def create(self, comp):
46 print comp.produceHTML()
48 html = HTMLOutputDevice()
50 class GUIOutputDevice(OutputDevice):
52 def create(self, comp):
53 comp.createGUIScreen(self.parent)
58 self.delayTimer = eTimer()
59 self.delayTimer.timeout.get().append(self.processDelay)
61 self.currentDialog = None
63 self.dialogStack = [ ]
65 def processDelay(self):
66 self.currentDialog.doClose()
67 if self.currentWindow != None:
68 self.currentWindow.hide()
70 del self.currentDialog
71 del self.currentWindow
73 if len(self.dialogStack):
74 (self.currentDialog, self.currentWindow) = self.dialogStack.pop()
75 self.currentWindow.show()
77 def open(self, screen):
78 if self.currentDialog:
79 self.dialogStack.append((self.currentDialog, self.currentWindow))
80 self.currentWindow.hide()
82 self.currentDialog = screen
85 if self.desktop != None:
86 self.currentWindow = wnd = eWindow(self.desktop)
87 # wnd.setTitle("Screen from python!")
88 # wnd.move(ePoint(300, 100))
89 # wnd.resize(eSize(300, 300))
91 gui = GUIOutputDevice()
93 gui.create(self.currentDialog)
95 applyGUIskin(self.currentDialog, wnd, None, screen.__class__.__name__)
99 self.currentWindow = None
101 def keyEvent(self, code):
102 # print "code " + str(code)
104 self.currentDialog["okbutton"].instance.push()
107 self.currentDialog["channelSwitcher"].instance.push()
109 if code >= 0x30 and code <= 0x39:
111 self.currentDialog["menu"].instance.moveSelection(code - 0x31)
113 self.currentDialog["list"].instance.moveSelection(code - 0x31)
116 self.delayTimer.start(0, 1)
120 session.desktop = getDesktop()
122 session.open(infoBar())
124 CONNECT(keyPressedSignal(), session.keyEvent)
131 # first, setup a screen
134 # now, run the mainloop