Simplify UI layout API by removing pre_render()

This commit is contained in:
henryruhs 2024-09-28 22:21:06 +02:00
parent 786a50b90a
commit 0224fd9861
5 changed files with 6 additions and 23 deletions

View File

@ -25,7 +25,6 @@ UI_LAYOUT_MODULES : List[ModuleType] = []
UI_LAYOUT_METHODS =\ UI_LAYOUT_METHODS =\
[ [
'pre_check', 'pre_check',
'pre_render',
'render', 'render',
'listen', 'listen',
'run' 'run'
@ -83,7 +82,7 @@ def launch() -> None:
with gradio.Blocks(theme = get_theme(), css = get_css(), title = metadata.get('name') + ' ' + metadata.get('version'), fill_width = True) as ui: with gradio.Blocks(theme = get_theme(), css = get_css(), title = metadata.get('name') + ' ' + metadata.get('version'), fill_width = True) as ui:
for ui_layout in state_manager.get_item('ui_layouts'): for ui_layout in state_manager.get_item('ui_layouts'):
ui_layout_module = load_ui_layout_module(ui_layout) ui_layout_module = load_ui_layout_module(ui_layout)
if ui_layout_module.pre_render():
if ui_layouts_total > 1: if ui_layouts_total > 1:
with gradio.Tab(ui_layout): with gradio.Tab(ui_layout):
ui_layout_module.render() ui_layout_module.render()

View File

@ -23,10 +23,6 @@ def pre_check() -> bool:
return False return False
def pre_render() -> bool:
return True
def render() -> gradio.Blocks: def render() -> gradio.Blocks:
with gradio.Blocks() as layout: with gradio.Blocks() as layout:
with gradio.Row(): with gradio.Row():

View File

@ -8,10 +8,6 @@ def pre_check() -> bool:
return True return True
def pre_render() -> bool:
return True
def render() -> gradio.Blocks: def render() -> gradio.Blocks:
with gradio.Blocks() as layout: with gradio.Blocks() as layout:
with gradio.Row(): with gradio.Row():

View File

@ -8,10 +8,6 @@ def pre_check() -> bool:
return True return True
def pre_render() -> bool:
return True
def render() -> gradio.Blocks: def render() -> gradio.Blocks:
with gradio.Blocks() as layout: with gradio.Blocks() as layout:
with gradio.Row(): with gradio.Row():

View File

@ -8,10 +8,6 @@ def pre_check() -> bool:
return True return True
def pre_render() -> bool:
return True
def render() -> gradio.Blocks: def render() -> gradio.Blocks:
with gradio.Blocks() as layout: with gradio.Blocks() as layout:
with gradio.Row(): with gradio.Row():