From 4f8490cd5630823ac44de8b5c5e4325bdbbea7fa Mon Sep 17 00:00:00 2001
From: DepFA <35278260+dfaker@users.noreply.github.com>
Date: Sat, 1 Oct 2022 18:33:31 +0100
Subject: add restart button
---
modules/ui.py | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
(limited to 'modules/ui.py')
diff --git a/modules/ui.py b/modules/ui.py
index 15572bb0..ec6aaa28 100644
--- a/modules/ui.py
+++ b/modules/ui.py
@@ -1002,6 +1002,17 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo, run_modelmerger):
_js='function(){}'
)
+ def request_restart():
+ settings_interface.gradio_ref.do_restart = True
+
+ restart_gradio = gr.Button(value='Restart Gradio and Refresh Scripts')
+ restart_gradio.click(
+ fn=request_restart,
+ inputs=[],
+ outputs=[],
+ _js='function(){document.body.innerHTML=\'
Reloading
\';setTimeout(function(){location.reload()},2000)}'
+ )
+
if column is not None:
column.__exit__()
@@ -1026,7 +1037,9 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo, run_modelmerger):
css += css_hide_progressbar
with gr.Blocks(css=css, analytics_enabled=False, title="Stable Diffusion") as demo:
-
+
+ settings_interface.gradio_ref = demo
+
with gr.Tabs() as tabs:
for interface, label, ifid in interfaces:
with gr.TabItem(label, id=ifid):
--
cgit v1.2.1
From afaa03c5fd05f48ed9c9f15558ea6f0bc4f61628 Mon Sep 17 00:00:00 2001
From: DepFA <35278260+dfaker@users.noreply.github.com>
Date: Sat, 1 Oct 2022 22:43:45 +0100
Subject: add redefinition guard to gradio_routes_templates_response
---
modules/ui.py | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
(limited to 'modules/ui.py')
diff --git a/modules/ui.py b/modules/ui.py
index ec6aaa28..fd057916 100644
--- a/modules/ui.py
+++ b/modules/ui.py
@@ -1219,12 +1219,13 @@ for filename in sorted(os.listdir(jsdir)):
javascript += f"\n"
-def template_response(*args, **kwargs):
- res = gradio_routes_templates_response(*args, **kwargs)
- res.body = res.body.replace(b'', f'{javascript}'.encode("utf8"))
- res.init_headers()
- return res
+if 'gradio_routes_templates_response' not in globals():
+ def template_response(*args, **kwargs):
+ res = gradio_routes_templates_response(*args, **kwargs)
+ res.body = res.body.replace(b'', f'{javascript}'.encode("utf8"))
+ res.init_headers()
+ return res
+ gradio_routes_templates_response = gradio.routes.templates.TemplateResponse
+ gradio.routes.templates.TemplateResponse = template_response
-gradio_routes_templates_response = gradio.routes.templates.TemplateResponse
-gradio.routes.templates.TemplateResponse = template_response
--
cgit v1.2.1
From 6048002dade91b82b1ce9fea3c6ff5b5c1f8c990 Mon Sep 17 00:00:00 2001
From: DepFA <35278260+dfaker@users.noreply.github.com>
Date: Sat, 1 Oct 2022 23:10:07 +0100
Subject: Add scope warning to refresh button
---
modules/ui.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'modules/ui.py')
diff --git a/modules/ui.py b/modules/ui.py
index fd057916..72846a12 100644
--- a/modules/ui.py
+++ b/modules/ui.py
@@ -1005,7 +1005,7 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo, run_modelmerger):
def request_restart():
settings_interface.gradio_ref.do_restart = True
- restart_gradio = gr.Button(value='Restart Gradio and Refresh Scripts')
+ restart_gradio = gr.Button(value='Restart Gradio and Refresh components (Custom Scripts, ui.py, js and css only)', variant='primary')
restart_gradio.click(
fn=request_restart,
inputs=[],
--
cgit v1.2.1
From 027c5aae5546ff3650347cb3c2b87df4415ab900 Mon Sep 17 00:00:00 2001
From: DepFA <35278260+dfaker@users.noreply.github.com>
Date: Sat, 1 Oct 2022 23:29:26 +0100
Subject: update reloading message style
---
modules/ui.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'modules/ui.py')
diff --git a/modules/ui.py b/modules/ui.py
index 72846a12..7b2359c2 100644
--- a/modules/ui.py
+++ b/modules/ui.py
@@ -1010,7 +1010,7 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo, run_modelmerger):
fn=request_restart,
inputs=[],
outputs=[],
- _js='function(){document.body.innerHTML=\'Reloading
\';setTimeout(function(){location.reload()},2000)}'
+ _js='function(){document.body.innerHTML=\'Reloading...
\';setTimeout(function(){location.reload()},2000)}'
)
if column is not None:
--
cgit v1.2.1
From 0aa354bd5e811e2b41b17a3052cf5d4c8190d533 Mon Sep 17 00:00:00 2001
From: DepFA <35278260+dfaker@users.noreply.github.com>
Date: Sun, 2 Oct 2022 00:13:47 +0100
Subject: remove styling from python side
---
modules/ui.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'modules/ui.py')
diff --git a/modules/ui.py b/modules/ui.py
index 7b2359c2..cb859ac4 100644
--- a/modules/ui.py
+++ b/modules/ui.py
@@ -1010,7 +1010,7 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo, run_modelmerger):
fn=request_restart,
inputs=[],
outputs=[],
- _js='function(){document.body.innerHTML=\'Reloading...
\';setTimeout(function(){location.reload()},2000)}'
+ _js='function(){restart_reload()}'
)
if column is not None:
--
cgit v1.2.1
From 07e40ad7f23472fc1c781fe1cc6c1ee403413918 Mon Sep 17 00:00:00 2001
From: DepFA <35278260+dfaker@users.noreply.github.com>
Date: Sun, 2 Oct 2022 01:19:55 +0100
Subject: add custom script body only refresh option
---
modules/ui.py | 11 +++++++++++
1 file changed, 11 insertions(+)
(limited to 'modules/ui.py')
diff --git a/modules/ui.py b/modules/ui.py
index cb859ac4..eb7c0585 100644
--- a/modules/ui.py
+++ b/modules/ui.py
@@ -1012,6 +1012,17 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo, run_modelmerger):
outputs=[],
_js='function(){restart_reload()}'
)
+
+ def reload_scripts():
+ modules.scripts.reload_script_body_only()
+
+ reload_script_bodies = gr.Button(value='Reload custom script bodies (No ui updates, No restart)', variant='primary')
+ reload_script_bodies.click(
+ fn=reload_scripts,
+ inputs=[],
+ outputs=[],
+ _js='function(){}'
+ )
if column is not None:
column.__exit__()
--
cgit v1.2.1
From 2deea867814272f1f089b60e9ba8d587c16b2fb1 Mon Sep 17 00:00:00 2001
From: DepFA <35278260+dfaker@users.noreply.github.com>
Date: Sun, 2 Oct 2022 01:36:30 +0100
Subject: Put reload buttons in row and add secondary style
---
modules/ui.py | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
(limited to 'modules/ui.py')
diff --git a/modules/ui.py b/modules/ui.py
index eb7c0585..963a2c61 100644
--- a/modules/ui.py
+++ b/modules/ui.py
@@ -1002,27 +1002,30 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo, run_modelmerger):
_js='function(){}'
)
- def request_restart():
- settings_interface.gradio_ref.do_restart = True
+ with gr.Row():
+ reload_script_bodies = gr.Button(value='Reload custom script bodies (No ui updates, No restart)', variant='secondary')
+ restart_gradio = gr.Button(value='Restart Gradio and Refresh components (Custom Scripts, ui.py, js and css only)', variant='primary')
- restart_gradio = gr.Button(value='Restart Gradio and Refresh components (Custom Scripts, ui.py, js and css only)', variant='primary')
- restart_gradio.click(
- fn=request_restart,
- inputs=[],
- outputs=[],
- _js='function(){restart_reload()}'
- )
def reload_scripts():
modules.scripts.reload_script_body_only()
- reload_script_bodies = gr.Button(value='Reload custom script bodies (No ui updates, No restart)', variant='primary')
reload_script_bodies.click(
fn=reload_scripts,
inputs=[],
outputs=[],
_js='function(){}'
)
+
+ def request_restart():
+ settings_interface.gradio_ref.do_restart = True
+
+ restart_gradio.click(
+ fn=request_restart,
+ inputs=[],
+ outputs=[],
+ _js='function(){restart_reload()}'
+ )
if column is not None:
column.__exit__()
--
cgit v1.2.1
From e808096cf641d868f88465515d70d40fc46125d4 Mon Sep 17 00:00:00 2001
From: DepFA <35278260+dfaker@users.noreply.github.com>
Date: Sun, 2 Oct 2022 19:26:06 +0100
Subject: correct indent
---
modules/ui.py | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
(limited to 'modules/ui.py')
diff --git a/modules/ui.py b/modules/ui.py
index 963a2c61..6b30f84b 100644
--- a/modules/ui.py
+++ b/modules/ui.py
@@ -1003,12 +1003,12 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo, run_modelmerger):
)
with gr.Row():
- reload_script_bodies = gr.Button(value='Reload custom script bodies (No ui updates, No restart)', variant='secondary')
- restart_gradio = gr.Button(value='Restart Gradio and Refresh components (Custom Scripts, ui.py, js and css only)', variant='primary')
+ reload_script_bodies = gr.Button(value='Reload custom script bodies (No ui updates, No restart)', variant='secondary')
+ restart_gradio = gr.Button(value='Restart Gradio and Refresh components (Custom Scripts, ui.py, js and css only)', variant='primary')
def reload_scripts():
- modules.scripts.reload_script_body_only()
+ modules.scripts.reload_script_body_only()
reload_script_bodies.click(
fn=reload_scripts,
@@ -1018,7 +1018,7 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo, run_modelmerger):
)
def request_restart():
- settings_interface.gradio_ref.do_restart = True
+ settings_interface.gradio_ref.do_restart = True
restart_gradio.click(
fn=request_restart,
@@ -1234,12 +1234,11 @@ for filename in sorted(os.listdir(jsdir)):
if 'gradio_routes_templates_response' not in globals():
- def template_response(*args, **kwargs):
- res = gradio_routes_templates_response(*args, **kwargs)
- res.body = res.body.replace(b'', f'{javascript}'.encode("utf8"))
- res.init_headers()
- return res
-
- gradio_routes_templates_response = gradio.routes.templates.TemplateResponse
- gradio.routes.templates.TemplateResponse = template_response
-
+ def template_response(*args, **kwargs):
+ res = gradio_routes_templates_response(*args, **kwargs)
+ res.body = res.body.replace(b'', f'{javascript}'.encode("utf8"))
+ res.init_headers()
+ return res
+
+ gradio_routes_templates_response = gradio.routes.templates.TemplateResponse
+ gradio.routes.templates.TemplateResponse = template_response
--
cgit v1.2.1