7 from skin import applyGUIskin
10 def CONNECT(slot, fnc):
11 slot.get().append(fnc)
13 def DISCONNECT(slot, fnc):
14 slot.get().remove(fnc)
16 # A screen is a function which instanciates all components of a screen into a temporary component.
17 # Thus, the global stuff is a screen, too.
18 # In a screen, components can either be instanciated from the class-tree, cloned (copied) or
19 # "linked" from the instance tree.
20 # A screen itself lives as the container of the components, so a screen is a component, too.
22 # we thus have one (static) hierarchy of screens (classes, not instances)
23 # and one with the instanciated components itself (both global and dynamic)
25 def dump(dir, p = ""):
26 if isinstance(dir, dict):
27 for (entry, val) in dir.items():
28 dump(val, p + "/" + entry)
29 print p + ":" + str(dir.__class__)
35 screens["global"](components)
38 components["$001"] = screens["testDialog"]()
43 #print "*** instances:"
49 def create(self, screen): pass
53 class HTMLOutputDevice(OutputDevice):
54 def create(self, comp):
55 print comp.produceHTML()
57 html = HTMLOutputDevice()
59 class GUIOutputDevice(OutputDevice):
61 def create(self, comp):
62 comp.createGUIScreen(self.parent)
67 self.delayTimer = eTimer()
68 self.delayTimer.timeout.get().append(self.processDelay)
70 self.currentDialog = None
72 def processDelay(self):
73 self.currentDialog.close()
74 if self.currentWindow != None:
75 self.currentWindow.hide()
77 del self.currentDialog
78 del self.currentWindow
80 self.open(screens["testDialog"]())
82 def open(self, screen):
83 self.currentDialog = screen
86 if self.desktop != None:
87 self.currentWindow = wnd = eWindow(self.desktop)
88 wnd.setTitle("Screen from python!")
89 wnd.move(ePoint(300, 100))
90 wnd.resize(eSize(300, 300))
92 gui = GUIOutputDevice()
94 gui.create(self.currentDialog)
96 applyGUIskin(self.currentDialog, None, screen.__class__.__name__)
100 self.currentWindow = None
102 def keyEvent(self, code):
103 # print "code " + str(code)
105 self.currentDialog.data["okbutton"]["instance"].push()
107 if code >= 0x30 and code <= 0x39:
108 self.currentDialog.data["menu"]["instance"].moveSelection(code - 0x31)
111 self.delayTimer.start(0, 1)
115 session.desktop = getDesktop()
117 session.open(screens["clockDisplay"](components["clock"]))
118 # session.open(screens["testDialog"]())
120 # simple reason for this helper function: we want to call the currently
121 # active "okbutton", even when we changed the dialog
123 # more complicated reason: we don't want to hold a reference.
125 # session.currentDialog.data["okbutton"]["instance"].push()
126 # session.currentDialog["okbutton"].setText("hello!")
129 # CONNECT(tmr.timeout, blub)
132 CONNECT(keyPressedSignal(), session.keyEvent)
139 # first, setup a screen
142 # now, run the mainloop