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
73 retval = self.currentDialog.returnValue
75 if self.currentDialog.isTmp:
76 self.currentDialog.doClose()
78 del self.currentDialog.instance
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)
124 readSkin(dlg, None, dlg.skinName, self.desktop)
126 # create GUI view of this dialog
127 assert self.desktop != None
128 dlg.instance = eWindow(self.desktop)
129 applyAllAttributes(dlg.instance, self.desktop, dlg.skinAttributes)
130 gui = GUIOutputDevice()
131 gui.parent = dlg.instance
132 gui.create(dlg, self.desktop)
136 def pushCurrent(self):
137 if self.currentDialog:
138 self.dialogStack.append(self.currentDialog)
141 def popCurrent(self):
142 if len(self.dialogStack):
143 self.currentDialog = self.dialogStack.pop()
146 self.currentDialog = None
148 def execDialog(self, dialog):
150 self.currentDialog = dialog
151 self.currentDialog.isTmp = False
152 self.currentDialog.callback = None # would cause re-entrancy problems.
155 def openWithCallback(self, callback, screen, *arguments):
156 dlg = self.open(screen, *arguments)
157 dlg.callback = callback
159 def open(self, screen, *arguments):
161 dlg = self.currentDialog = self.instantiateDialog(screen, *arguments)
167 def keyEvent(self, code):
168 print "code " + str(code)
170 def close(self, *retval):
171 self.currentDialog.returnValue = retval
172 self.delayTimer.start(0, 1)
176 session.desktop = getDesktop()
178 session.nav = Navigation()
180 screensToRun = listActiveWizards()
181 screensToRun.append(Screens.InfoBar.InfoBar)
183 def runNextScreen(session, screensToRun, *result):
187 screen = screensToRun[0]
189 if len(screensToRun):
190 session.openWithCallback(boundFunction(runNextScreen, session, screensToRun[1:]), screen)
194 runNextScreen(session, screensToRun)
196 CONNECT(keyPressedSignal(), session.keyEvent)
202 session.nav.shutdown()
207 keymapparser.readKeymap()
209 skin.loadSkin(getDesktop())
211 import Components.InputDevice
212 Components.InputDevice.InitInputDevices()
214 import Components.AVSwitch
215 Components.AVSwitch.InitAVSwitch()
217 import Components.Network
218 Components.Network.InitNetwork()
220 import Components.Lcd
221 Components.Lcd.InitLcd()
223 import Components.SetupDevices
224 Components.SetupDevices.InitSetupDevices()
226 import Components.RFmod
227 Components.RFmod.InitRFmod()
229 import Components.NimManager
231 # first, setup a screen
235 print 'EXCEPTION IN PYTHON STARTUP CODE:'
237 traceback.print_exc(file=sys.stdout)