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 = [ ]
27 # already shown is false until the screen is really shown (after creation)
28 self.already_shown = False
32 # in order to support screens *without* a help,
33 # we need the list in every screen. how ironic.
36 self.close_on_next_exec = None
38 # stand alone screens (for example web screens)
39 # don't care about having or not having focus.
40 self.stand_alone = False
43 self.active_components = [ ]
44 if self.close_on_next_exec is not None:
45 tmp = self.close_on_next_exec
46 self.close_on_next_exec = None
50 single = self.onFirstExecBegin
51 self.onFirstExecBegin = []
52 for x in self.onExecBegin + single:
54 if not self.stand_alone and self.session.current_dialog != self:
57 # assert self.session == None, "a screen can only exec once per time"
58 # self.session = session
60 for val in self.values() + self.renderer:
62 if not self.stand_alone and self.session.current_dialog != self:
64 self.active_components.append(val)
68 for x in self.onShown:
72 # for (name, val) in self.items():
73 for val in self.active_components:
75 del self.active_components
76 # assert self.session != None, "execEnd on non-execing screen!"
80 # never call this directly - it will be called from the session!
83 for x in self.onClose:
86 # fixup circular references
90 # first disconnect all render from their sources.
91 # we might split this out into a "unskin"-call,
92 # but currently we destroy the screen afterwards
94 for val in self.renderer:
95 val.disconnectAll() # disconnected converter/sources and probably destroy them
98 for (name, val) in self.items():
102 for val in self.renderer:
107 # really delete all elements now
108 self.__dict__.clear()
110 def close(self, *retval):
112 self.close_on_next_exec = retval
114 self.session.close(self, *retval)
116 def setFocus(self, o):
117 self.instance.setFocus(o.instance)
120 if (self.shown and self.already_shown) or not self.instance:
123 self.already_shown = True
125 for x in self.onShow:
127 for val in self.values() + self.renderer:
128 if isinstance(val, GUIComponent) or isinstance(val, Source):
132 if not self.shown or not self.instance:
136 for x in self.onHide:
138 for val in self.values() + self.renderer:
139 if isinstance(val, GUIComponent) or isinstance(val, Source):
143 return str(type(self))