4 from Components.Language import language
12 import ServiceReference
14 from Navigation import Navigation
16 from skin import readSkin, applyAllAttributes
18 from Components.config import configfile
19 from Screens.Wizard import wizardManager
20 from Screens.StartWizard import *
21 from Tools.BoundFunction import boundFunction
25 def dump(dir, p = ""):
26 if isinstance(dir, dict):
27 for (entry, val) in dir.items():
28 dump(val, p + "(dict)/" + entry)
29 if hasattr(dir, "__dict__"):
30 for name, value in dir.__dict__.items():
31 if not had.has_key(str(value)):
33 dump(value, p + "/" + str(name))
35 print p + "/" + str(name) + ":" + str(dir.__class__) + "(cycle)"
37 print p + ":" + str(dir)
39 # + ":" + str(dir.__class__)
44 def create(self, screen): pass
48 class HTMLOutputDevice(OutputDevice):
49 def create(self, comp):
50 print comp.produceHTML()
52 html = HTMLOutputDevice()
54 class GUIOutputDevice(OutputDevice):
56 def create(self, comp, desktop):
57 comp.createGUIScreen(self.parent, desktop)
62 self.delayTimer = eTimer()
63 self.delayTimer.timeout.get().append(self.processDelay)
65 self.currentDialog = None
67 self.dialogStack = [ ]
69 def processDelay(self):
72 callback = self.currentDialog.callback
74 retval = self.currentDialog.returnValue
76 if self.currentDialog.isTmp:
77 self.currentDialog.doClose()
79 del self.currentDialog.instance
80 # dump(self.currentDialog)
81 del self.currentDialog
83 del self.currentDialog.callback
86 if callback is not None:
90 c = self.currentDialog
93 # when execBegin opened a new dialog, don't bother showing the old one.
94 if c == self.currentDialog:
98 self.currentDialog.execEnd()
99 self.currentDialog.instance.hide()
101 def create(self, screen, arguments):
102 # creates an instance of 'screen' (which is a class)
104 return screen(self, *arguments)
106 errstr = "Screen %s(%s): %s" % (str(screen), str(arguments), sys.exc_info()[0])
108 traceback.print_exc(file=sys.stdout)
112 def instantiateDialog(self, screen, *arguments):
116 dlg = self.create(screen, arguments)
118 print 'EXCEPTION IN DIALOG INIT CODE, ABORTING:'
120 traceback.print_exc(file=sys.stdout)
125 readSkin(dlg, None, dlg.skinName, self.desktop)
127 # create GUI view of this dialog
128 assert self.desktop != None
129 dlg.instance = eWindow(self.desktop)
130 applyAllAttributes(dlg.instance, self.desktop, dlg.skinAttributes)
131 gui = GUIOutputDevice()
132 gui.parent = dlg.instance
133 gui.create(dlg, self.desktop)
137 def pushCurrent(self):
138 if self.currentDialog:
139 self.dialogStack.append(self.currentDialog)
142 def popCurrent(self):
143 if len(self.dialogStack):
144 self.currentDialog = self.dialogStack.pop()
147 self.currentDialog = None
149 def execDialog(self, dialog):
151 self.currentDialog = dialog
152 self.currentDialog.isTmp = False
153 self.currentDialog.callback = None # would cause re-entrancy problems.
156 def openWithCallback(self, callback, screen, *arguments):
157 dlg = self.open(screen, *arguments)
158 dlg.callback = callback
160 def open(self, screen, *arguments):
162 dlg = self.currentDialog = self.instantiateDialog(screen, *arguments)
168 def keyEvent(self, code):
169 print "code " + str(code)
171 def close(self, *retval):
172 self.currentDialog.returnValue = retval
173 self.delayTimer.start(0, 1)
177 session.desktop = getDesktop()
179 session.nav = Navigation()
181 screensToRun = wizardManager.getWizards()
182 screensToRun.append(Screens.InfoBar.InfoBar)
184 def runNextScreen(session, screensToRun, *result):
188 screen = screensToRun[0]
190 if len(screensToRun):
191 session.openWithCallback(boundFunction(runNextScreen, session, screensToRun[1:]), screen)
195 runNextScreen(session, screensToRun)
197 CONNECT(keyPressedSignal(), session.keyEvent)
203 session.nav.shutdown()
208 keymapparser.readKeymap()
210 skin.loadSkin(getDesktop())
212 import Components.InputDevice
213 Components.InputDevice.InitInputDevices()
215 import Components.AVSwitch
216 Components.AVSwitch.InitAVSwitch()
218 import Components.Network
219 Components.Network.InitNetwork()
221 import Components.Lcd
222 Components.Lcd.InitLcd()
224 import Components.SetupDevices
225 Components.SetupDevices.InitSetupDevices()
227 import Components.RFmod
228 Components.RFmod.InitRFmod()
230 import Components.NimManager
232 # first, setup a screen
236 print 'EXCEPTION IN PYTHON STARTUP CODE:'
238 traceback.print_exc(file=sys.stdout)