-
Notifications
You must be signed in to change notification settings - Fork 0
/
ModUI.py
60 lines (46 loc) · 1.13 KB
/
ModUI.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import TermUI as tui
import TermCanvas as tc
import Terminal as trm
import TermIntr as ti
from threading import Thread,Lock
thread=None
root=None
stack=tui.ZStack()
intr=ti.Group()
def addElem(element,index=0):
stack.insertChild(element,index)
root.frames.schedule(0,tui.sched.framesLater)
def removeElem(element):
stack.disownChild(element)
root.frames.schedule(0,tui.sched.framesLater)
def addIntr(added):
intr.addIChild(added)
def removeIntr(added):
intr.orphanIChild(added)
def modInit(modules,config,lock):
global thread,explosionKey
completed=Lock()
completed.acquire()
tc.NOCTRLC_CANVAS=not config["CtrlCSigint"]
def main(cnv):
global root,stack,intr
nonlocal modules,completed
root=tui.Root(
cnv,
stack
)
intrRoot=ti.IntrRoot(
root.frames,
intr
)
completed.release()
modules.quitlock.quitLock.waitUnlock()
thread=Thread(target=tc.canvasApp,args=(main,))
thread.start()
completed.acquire()
addElem(tui.FrameRoller().align(alignV="bottom",alignH="right"))
explosionKey=ti.Button("explode",config["ExplosionKey"])
addIntr(explosionKey)
@explosionKey.onToggle
def boom(*_):
raise StopIteration