-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblock.py
37 lines (30 loc) · 818 Bytes
/
block.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
import gradio as gr
from enum import Enum
import secrets
class BlockType(Enum):
INPUT = 0
OUTPUT = 1
SPLIT = 2
COMBINE = 3
CONDITIONAL = 4
class Block:
def __init__(self, heading: str, label: str):
self.heading = heading
self.label = label
self.id = secrets.token_hex(16)
def html_contents(self):
return f"<p>{self.label}</p>"
def to_html(self):
html_string = f"""
<div id="{self.id}" class="block">
<div id="{self.id}header" class="block-header">{self.heading}</div>
{self.html_contents()}
</div>
""".strip()
return html_string
class InputBlock(Block):
def __init__(self):
super().__init__("INPUT", "Input Block")
class OutputBlock(Block):
def __init__(self):
super().__init__("OUTPUT", "Output Block")