-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomponent.py
More file actions
39 lines (32 loc) · 895 Bytes
/
component.py
File metadata and controls
39 lines (32 loc) · 895 Bytes
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
class Component:
pass
class Component:
def __init__(self,width:int,height:int,name:str,parent:Component):
self.width=width
self.height=height
self.name=name
self.visible: bool=True
self.focused: bool=False
self.parent=parent
self.is_view_layout: bool = False
# Handle input
def input(self,text:str):
pass
def onfocus(self):
self.focused=True
def onunfocus(self):
self.focused=False
def show(self):
self.visible=True
def hide(self):
self.visible=False
def get_layout(self):
if self.parent == None:
return None
if self.parent.is_view_layout:
return self.parent
else:
return self.parent.get_layout()
# Render the component
def view(self) -> str:
return "Hello World!"