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 Screens.TutorialWizard import *
22 from Tools.BoundFunction import boundFunction
26 def dump(dir, p = ""):
27 if isinstance(dir, dict):
28 for (entry, val) in dir.items():
29 dump(val, p + "(dict)/" + entry)
30 if hasattr(dir, "__dict__"):
31 for name, value in dir.__dict__.items():
32 if not had.has_key(str(value)):
34 dump(value, p + "/" + str(name))
36 print p + "/" + str(name) + ":" + str(dir.__class__) + "(cycle)"
38 print p + ":" + str(dir)
40 # + ":" + str(dir.__class__)
45 def create(self, screen): pass
49 class HTMLOutputDevice(OutputDevice):
50 def create(self, comp):
51 print comp.produceHTML()
53 html = HTMLOutputDevice()
55 class GUIOutputDevice(OutputDevice):
57 def create(self, comp, desktop):
58 comp.createGUIScreen(self.parent, desktop)
63 self.delayTimer = eTimer()
64 self.delayTimer.timeout.get().append(self.processDelay)
66 self.currentDialog = None
68 self.dialogStack = [ ]
70 def processDelay(self):
73 callback = self.currentDialog.callback
75 retval = self.currentDialog.returnValue
77 if self.currentDialog.isTmp:
78 self.currentDialog.doClose()
79 # dump(self.currentDialog)
80 del self.currentDialog
82 del self.currentDialog.callback
85 if callback is not None:
89 c = self.currentDialog
92 # when execBegin opened a new dialog, don't bother showing the old one.
93 if c == self.currentDialog:
97 self.currentDialog.execEnd()
98 self.currentDialog.instance.hide()
100 def create(self, screen, arguments):
101 # creates an instance of 'screen' (which is a class)
103 return screen(self, *arguments)
105 errstr = "Screen %s(%s): %s" % (str(screen), str(arguments), sys.exc_info()[0])
107 traceback.print_exc(file=sys.stdout)
111 def instantiateDialog(self, screen, *arguments):
115 dlg = self.create(screen, arguments)
117 print 'EXCEPTION IN DIALOG INIT CODE, ABORTING:'
119 traceback.print_exc(file=sys.stdout)
127 readSkin(dlg, None, dlg.skinName, self.desktop)
129 # create GUI view of this dialog
130 assert self.desktop != None
131 dlg.instance = eWindow(self.desktop)
132 applyAllAttributes(dlg.instance, self.desktop, dlg.skinAttributes)
133 gui = GUIOutputDevice()
134 gui.parent = dlg.instance
135 gui.create(dlg, self.desktop)
139 def pushCurrent(self):
140 if self.currentDialog:
141 self.dialogStack.append(self.currentDialog)
144 def popCurrent(self):
145 if len(self.dialogStack):
146 self.currentDialog = self.dialogStack.pop()
149 self.currentDialog = None
151 def execDialog(self, dialog):
153 self.currentDialog = dialog
154 self.currentDialog.isTmp = False
155 self.currentDialog.callback = None # would cause re-entrancy problems.
158 def openWithCallback(self, callback, screen, *arguments):
159 dlg = self.open(screen, *arguments)
160 dlg.callback = callback
162 def open(self, screen, *arguments):
164 dlg = self.currentDialog = self.instantiateDialog(screen, *arguments)
170 def keyEvent(self, code):
171 print "code " + str(code)
173 def close(self, *retval):
174 self.currentDialog.returnValue = retval
175 self.delayTimer.start(0, 1)
179 session.desktop = getDesktop()
181 session.nav = Navigation()
183 screensToRun = wizardManager.getWizards()
184 screensToRun.append(Screens.InfoBar.InfoBar)
186 def runNextScreen(session, screensToRun, *result):
190 screen = screensToRun[0]
192 if len(screensToRun):
193 session.openWithCallback(boundFunction(runNextScreen, session, screensToRun[1:]), screen)
197 runNextScreen(session, screensToRun)
199 CONNECT(keyPressedSignal(), session.keyEvent)
205 session.nav.shutdown()
210 keymapparser.readKeymap()
212 skin.loadSkin(getDesktop())
214 import Components.InputDevice
215 Components.InputDevice.InitInputDevices()
217 import Components.AVSwitch
218 Components.AVSwitch.InitAVSwitch()
220 import Components.RecordingConfig
221 Components.RecordingConfig.InitRecordingConfig()
223 import Components.Network
224 Components.Network.InitNetwork()
226 import Components.Lcd
227 Components.Lcd.InitLcd()
229 import Components.SetupDevices
230 Components.SetupDevices.InitSetupDevices()
232 import Components.RFmod
233 Components.RFmod.InitRFmod()
235 import Components.NimManager
237 # first, setup a screen
241 print 'EXCEPTION IN PYTHON STARTUP CODE:'
243 traceback.print_exc(file=sys.stdout)