1 from Components.HTMLSkin import *
2 from Components.GUISkin import *
3 from Components.Sources.Source import Source
7 class Screen(dict, HTMLSkin, GUISkin):
11 def __init__(self, session):
12 self.skinName = self.__class__.__name__
13 self.session = session
14 GUISkin.__init__(self)
17 self.onFirstExecBegin = [ ]
18 self.onExecBegin = [ ]
29 # in order to support screens *without* a help,
30 # we need the list in every screen. how ironic.
33 self.close_on_next_exec = None
35 # stand alone screens (for example web screens)
36 # don't care about having or not having focus.
37 self.stand_alone = False
40 self.active_components = [ ]
41 if self.close_on_next_exec is not None:
42 tmp = self.close_on_next_exec
43 self.close_on_next_exec = None
47 single = self.onFirstExecBegin
48 self.onFirstExecBegin = []
49 for x in self.onExecBegin + single:
51 if not self.stand_alone and self.session.current_dialog != self:
54 # assert self.session == None, "a screen can only exec once per time"
55 # self.session = session
57 for val in self.values() + self.renderer:
59 if not self.stand_alone and self.session.current_dialog != self:
61 self.active_components.append(val)
65 for x in self.onShown:
69 # for (name, val) in self.items():
70 for val in self.active_components:
72 del self.active_components
73 # assert self.session != None, "execEnd on non-execing screen!"
77 # never call this directly - it will be called from the session!
80 for x in self.onClose:
83 # fixup circular references
87 # first disconnect all render from their sources.
88 # we might split this out into a "unskin"-call,
89 # but currently we destroy the screen afterwards
91 for val in self.renderer:
92 val.disconnectAll() # disconnected converter/sources and probably destroy them
95 for (name, val) in self.items():
99 for val in self.renderer:
104 # really delete all elements now
105 self.__dict__.clear()
107 def close(self, *retval):
109 self.close_on_next_exec = retval
111 self.session.close(self, *retval)
113 def setFocus(self, o):
114 self.instance.setFocus(o.instance)
116 def show(self, force = False):
117 if (self.shown and not force) or not self.instance:
121 for x in self.onShow:
123 for val in self.values() + self.renderer:
124 if isinstance(val, GUIComponent) or isinstance(val, Source):
128 if not self.shown or not self.instance:
132 for x in self.onHide:
134 for val in self.values() + self.renderer:
135 if isinstance(val, GUIComponent) or isinstance(val, Source):
139 return str(type(self))