-
Notifications
You must be signed in to change notification settings - Fork 0
/
WidgetStorage.py
43 lines (29 loc) · 1.07 KB
/
WidgetStorage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# WidgetStorage.py
_hSavedWidgets = {}
# ---------------------------------------------------------------------------
def saveWidget(name, widget):
# --- This is called for any widget created
# that has a 'name' key
global _hSavedWidgets
if name in _hSavedWidgets:
raise Exception(f"saveWidget(): There is already a widget"
f" named '{name}'")
_hSavedWidgets[name] = widget
# ---------------------------------------------------------------------------
def findWidgetByName(name):
global _hSavedWidgets
if name in _hSavedWidgets:
return _hSavedWidgets[name]
else:
raise Exception(f"findWidgetByName():"
f" There is no widget named '{name}'")
# ---------------------------------------------------------------------------
def removeSavedWidgets():
global _hSavedWidgets
_hSavedWidgets = {}
# ---------------------------------------------------------------------------
def numSavedWidgets():
global _hSavedWidgets
n = len(_hSavedWidgets)
return n
# ---------------------------------------------------------------------------