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
22 def dump(dir, p = ""):
23 if isinstance(dir, dict):
24 for (entry, val) in dir.items():
25 dump(val, p + "(dict)/" + entry)
26 if hasattr(dir, "__dict__"):
27 for name, value in dir.__dict__.items():
28 if not had.has_key(str(value)):
30 dump(value, p + "/" + str(name))
32 print p + "/" + str(name) + ":" + str(dir.__class__) + "(cycle)"
34 print p + ":" + str(dir)
36 # + ":" + str(dir.__class__)
41 def create(self, screen): pass
45 class HTMLOutputDevice(OutputDevice):
46 def create(self, comp):
47 print comp.produceHTML()
49 html = HTMLOutputDevice()
51 class GUIOutputDevice(OutputDevice):
53 def create(self, comp, desktop):
54 comp.createGUIScreen(self.parent, desktop)
59 self.delayTimer = eTimer()
60 self.delayTimer.timeout.get().append(self.processDelay)
62 self.currentDialog = None
64 self.dialogStack = [ ]
66 def processDelay(self):
69 callback = self.currentDialog.callback
70 retval = self.currentDialog.returnValue
72 if self.currentDialog.isTmp:
73 self.currentDialog.doClose()
75 del self.currentDialog.instance
76 # dump(self.currentDialog)
77 del self.currentDialog
79 del self.currentDialog.callback
82 if callback is not None:
86 self.currentDialog.execBegin()
87 self.currentDialog.instance.show()
90 self.currentDialog.execEnd()
91 self.currentDialog.instance.hide()
93 def create(self, screen, arguments):
94 # creates an instance of 'screen' (which is a class)
96 return screen(self, *arguments)
98 errstr = "Screen %s(%s): %s" % (str(screen), str(arguments), str(x))
99 raise TypeError(errstr)
101 def instantiateDialog(self, screen, *arguments):
105 dlg = self.create(screen, arguments)
107 print 'EXCEPTION IN DIALOG INIT CODE, ABORTING:'
109 traceback.print_exc(file=sys.stdout)
114 readSkin(dlg, None, dlg.skinName, self.desktop)
116 # create GUI view of this dialog
117 assert self.desktop != None
118 dlg.instance = eWindow(self.desktop)
119 applyAllAttributes(dlg.instance, self.desktop, dlg.skinAttributes)
120 gui = GUIOutputDevice()
121 gui.parent = dlg.instance
122 gui.create(dlg, self.desktop)
126 def pushCurrent(self):
127 if self.currentDialog:
128 self.dialogStack.append(self.currentDialog)
131 def popCurrent(self):
132 if len(self.dialogStack):
133 self.currentDialog = self.dialogStack.pop()
136 def execDialog(self, dialog):
138 self.currentDialog = dialog
139 self.currentDialog.isTmp = False
140 self.currentDialog.callback = None # would cause re-entrancy problems.
143 def openWithCallback(self, callback, screen, *arguments):
144 self.open(screen, *arguments)
145 self.currentDialog.callback = callback
147 def open(self, screen, *arguments):
149 self.currentDialog = self.instantiateDialog(screen, *arguments)
150 self.currentDialog.isTmp = True
151 self.currentDialog.callback = None
154 def keyEvent(self, code):
155 print "code " + str(code)
157 def close(self, *retval):
158 self.currentDialog.returnValue = retval
159 self.delayTimer.start(0, 1)
164 session.desktop = getDesktop()
166 session.nav = Navigation()
168 session.open(Screens.InfoBar.InfoBar)
170 CONNECT(keyPressedSignal(), session.keyEvent)
176 session.nav.shutdown()
181 keymapparser.readKeymap()
183 skin.loadSkin(getDesktop())
185 import Components.InputDevice
186 Components.InputDevice.InitInputDevices()
188 import Components.AVSwitch
189 Components.AVSwitch.InitAVSwitch()
191 import Components.Network
192 Components.Network.InitNetwork()
194 import Components.Lcd
195 Components.Lcd.InitLcd()
197 import Components.SetupDevices
198 Components.SetupDevices.InitSetupDevices()
200 import Components.RFmod
201 Components.RFmod.InitRFmod()
203 import Components.NimManager
205 # first, setup a screen
209 print 'EXCEPTION IN PYTHON STARTUP CODE:'
211 traceback.print_exc(file=sys.stdout)