10 import ServiceReference
12 from Navigation import Navigation
14 from skin import readSkin, applyAllAttributes
17 # A screen is a function which instanciates all components of a screen into a temporary component.
18 # Thus, the global stuff is a screen, too.
19 # In a screen, components can either be instanciated from the class-tree, cloned (copied) or
20 # "linked" from the instance tree.
21 # A screen itself lives as the container of the components, so a screen is a component, too.
23 # we thus have one (static) hierarchy of screens (classes, not instances)
24 # and one with the instanciated components itself (both global and dynamic)
28 def dump(dir, p = ""):
29 if isinstance(dir, dict):
30 for (entry, val) in dir.items():
31 dump(val, p + "(dict)/" + entry)
32 if hasattr(dir, "__dict__"):
33 for name, value in dir.__dict__.items():
34 if not had.has_key(str(value)):
36 dump(value, p + "/" + str(name))
38 print p + "/" + str(name) + ":" + str(dir.__class__) + "(cycle)"
40 print p + ":" + str(dir)
42 # + ":" + str(dir.__class__)
47 def create(self, screen): pass
51 class HTMLOutputDevice(OutputDevice):
52 def create(self, comp):
53 print comp.produceHTML()
55 html = HTMLOutputDevice()
57 class GUIOutputDevice(OutputDevice):
59 def create(self, comp, desktop):
60 comp.createGUIScreen(self.parent, desktop)
65 self.delayTimer = eTimer()
66 self.delayTimer.timeout.get().append(self.processDelay)
68 self.currentDialog = None
70 self.dialogStack = [ ]
72 def processDelay(self):
75 if self.currentDialog.isTmp:
76 self.currentDialog.doClose()
78 print sys.getrefcount(self.currentDialog)
79 del self.currentDialog.instance
80 # dump(self.currentDialog)
81 del self.currentDialog
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)
95 return screen(self, *arguments)
97 def instantiateDialog(self, screen, *arguments):
101 dlg = self.create(screen, arguments)
103 print 'EXCEPTION IN DIALOG INIT CODE, ABORTING:'
105 traceback.print_exc(file=sys.stdout)
110 readSkin(dlg, None, dlg.skinName, self.desktop)
112 # create GUI view of this dialog
113 assert self.desktop != None
114 dlg.instance = eWindow(self.desktop)
115 applyAllAttributes(dlg.instance, self.desktop, dlg.skinAttributes)
116 gui = GUIOutputDevice()
117 gui.parent = dlg.instance
118 gui.create(dlg, self.desktop)
122 def pushCurrent(self):
123 if self.currentDialog:
124 self.dialogStack.append(self.currentDialog)
127 def popCurrent(self):
128 if len(self.dialogStack):
129 self.currentDialog = self.dialogStack.pop()
132 def execDialog(self, dialog):
134 self.currentDialog = dialog
135 self.currentDialog.isTmp = False
138 def open(self, screen, *arguments):
140 self.currentDialog = self.instantiateDialog(screen, *arguments)
141 self.currentDialog.isTmp = True
144 def keyEvent(self, code):
145 print "code " + str(code)
148 self.delayTimer.start(0, 1)
153 session.desktop = getDesktop()
155 session.nav = Navigation()
157 session.open(Screens.InfoBar.InfoBar)
159 CONNECT(keyPressedSignal(), session.keyEvent)
163 session.nav.shutdown()
168 keymapparser.readKeymap()
170 skin.loadSkin(getDesktop())
172 import Components.InputDevice
173 Components.InputDevice.InitInputDevices()
175 import Components.SetupDevices
176 Components.SetupDevices.InitSetupDevices()
178 # first, setup a screen
182 print 'EXCEPTION IN PYTHON STARTUP CODE:'
184 traceback.print_exc(file=sys.stdout)
188 # now, run the mainloop
190 #pt = eDebugClassPtr()
191 #eDebugClass.getDebug(pt, 12)
195 #print "removing ptr..."
198 #print "p is " + str(p)
203 #bla = eDebugClass(2)