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 listActiveWizards
20 from Tools.BoundFunction import boundFunction
24 def dump(dir, p = ""):
25 if isinstance(dir, dict):
26 for (entry, val) in dir.items():
27 dump(val, p + "(dict)/" + entry)
28 if hasattr(dir, "__dict__"):
29 for name, value in dir.__dict__.items():
30 if not had.has_key(str(value)):
32 dump(value, p + "/" + str(name))
34 print p + "/" + str(name) + ":" + str(dir.__class__) + "(cycle)"
36 print p + ":" + str(dir)
38 # + ":" + str(dir.__class__)
43 def create(self, screen): pass
47 class HTMLOutputDevice(OutputDevice):
48 def create(self, comp):
49 print comp.produceHTML()
51 html = HTMLOutputDevice()
53 class GUIOutputDevice(OutputDevice):
55 def create(self, comp, desktop):
56 comp.createGUIScreen(self.parent, desktop)
61 self.delayTimer = eTimer()
62 self.delayTimer.timeout.get().append(self.processDelay)
64 self.currentDialog = None
66 self.dialogStack = [ ]
68 def processDelay(self):
71 callback = self.currentDialog.callback
72 retval = self.currentDialog.returnValue
74 if self.currentDialog.isTmp:
75 self.currentDialog.doClose()
77 del self.currentDialog.instance
78 # dump(self.currentDialog)
79 del self.currentDialog
81 del self.currentDialog.callback
84 if callback is not None:
88 self.currentDialog.execBegin()
89 self.currentDialog.instance.show()
92 self.currentDialog.execEnd()
93 self.currentDialog.instance.hide()
95 def create(self, screen, arguments):
96 # creates an instance of 'screen' (which is a class)
98 return screen(self, *arguments)
100 errstr = "Screen %s(%s): %s" % (str(screen), str(arguments), sys.exc_info()[0])
102 traceback.print_exc(file=sys.stdout)
106 def instantiateDialog(self, screen, *arguments):
110 dlg = self.create(screen, arguments)
112 print 'EXCEPTION IN DIALOG INIT CODE, ABORTING:'
114 traceback.print_exc(file=sys.stdout)
119 readSkin(dlg, None, dlg.skinName, self.desktop)
121 # create GUI view of this dialog
122 assert self.desktop != None
123 dlg.instance = eWindow(self.desktop)
124 applyAllAttributes(dlg.instance, self.desktop, dlg.skinAttributes)
125 gui = GUIOutputDevice()
126 gui.parent = dlg.instance
127 gui.create(dlg, self.desktop)
131 def pushCurrent(self):
132 if self.currentDialog:
133 self.dialogStack.append(self.currentDialog)
136 def popCurrent(self):
137 if len(self.dialogStack):
138 self.currentDialog = self.dialogStack.pop()
141 self.currentDialog = None
143 def execDialog(self, dialog):
145 self.currentDialog = dialog
146 self.currentDialog.isTmp = False
147 self.currentDialog.callback = None # would cause re-entrancy problems.
150 def openWithCallback(self, callback, screen, *arguments):
151 self.open(screen, *arguments)
152 self.currentDialog.callback = callback
154 def open(self, screen, *arguments):
156 self.currentDialog = self.instantiateDialog(screen, *arguments)
157 self.currentDialog.isTmp = True
158 self.currentDialog.callback = None
161 def keyEvent(self, code):
162 print "code " + str(code)
164 def close(self, *retval):
165 self.currentDialog.returnValue = retval
166 self.delayTimer.start(0, 1)
172 session.desktop = getDesktop()
174 session.nav = Navigation()
176 screensToRun = listActiveWizards()
177 screensToRun.append(Screens.InfoBar.InfoBar)
179 def runNextScreen(session, screensToRun, *result):
183 screen = screensToRun[0]
185 if len(screensToRun):
186 session.openWithCallback(boundFunction(runNextScreen, session, screensToRun[1:]), screen)
190 runNextScreen(session, screensToRun)
192 CONNECT(keyPressedSignal(), session.keyEvent)
198 session.nav.shutdown()
203 keymapparser.readKeymap()
205 skin.loadSkin(getDesktop())
207 import Components.InputDevice
208 Components.InputDevice.InitInputDevices()
210 import Components.AVSwitch
211 Components.AVSwitch.InitAVSwitch()
213 import Components.Network
214 Components.Network.InitNetwork()
216 import Components.Lcd
217 Components.Lcd.InitLcd()
219 import Components.SetupDevices
220 Components.SetupDevices.InitSetupDevices()
222 import Components.RFmod
223 Components.RFmod.InitRFmod()
225 import Components.NimManager
227 # first, setup a screen
231 print 'EXCEPTION IN PYTHON STARTUP CODE:'
233 traceback.print_exc(file=sys.stdout)