Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stable Diffusion Webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Stable Diffusion Webui
Commits
cb52279c
Commit
cb52279c
authored
Feb 17, 2024
by
AUTOMATIC1111
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge pull request #14947 from AUTOMATIC1111/open-button
option "open image button" open the actual dir
parent
33452184
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
17 deletions
+51
-17
modules/shared_options.py
modules/shared_options.py
+1
-0
modules/ui_common.py
modules/ui_common.py
+35
-17
modules/ui_tempdir.py
modules/ui_tempdir.py
+15
-0
No files found.
modules/shared_options.py
View file @
cb52279c
...
@@ -284,6 +284,7 @@ options_templates.update(options_section(('ui_gallery', "Gallery", "ui"), {
...
@@ -284,6 +284,7 @@ options_templates.update(options_section(('ui_gallery', "Gallery", "ui"), {
"sd_webui_modal_lightbox_icon_opacity"
:
OptionInfo
(
1
,
"Full page image viewer: control icon unfocused opacity"
,
gr
.
Slider
,
{
"minimum"
:
0.0
,
"maximum"
:
1
,
"step"
:
0.01
},
onchange
=
shared
.
reload_gradio_theme
)
.
info
(
'for mouse only'
)
.
needs_reload_ui
(),
"sd_webui_modal_lightbox_icon_opacity"
:
OptionInfo
(
1
,
"Full page image viewer: control icon unfocused opacity"
,
gr
.
Slider
,
{
"minimum"
:
0.0
,
"maximum"
:
1
,
"step"
:
0.01
},
onchange
=
shared
.
reload_gradio_theme
)
.
info
(
'for mouse only'
)
.
needs_reload_ui
(),
"sd_webui_modal_lightbox_toolbar_opacity"
:
OptionInfo
(
0.9
,
"Full page image viewer: tool bar opacity"
,
gr
.
Slider
,
{
"minimum"
:
0.0
,
"maximum"
:
1
,
"step"
:
0.01
},
onchange
=
shared
.
reload_gradio_theme
)
.
info
(
'for mouse only'
)
.
needs_reload_ui
(),
"sd_webui_modal_lightbox_toolbar_opacity"
:
OptionInfo
(
0.9
,
"Full page image viewer: tool bar opacity"
,
gr
.
Slider
,
{
"minimum"
:
0.0
,
"maximum"
:
1
,
"step"
:
0.01
},
onchange
=
shared
.
reload_gradio_theme
)
.
info
(
'for mouse only'
)
.
needs_reload_ui
(),
"gallery_height"
:
OptionInfo
(
""
,
"Gallery height"
,
gr
.
Textbox
)
.
info
(
"can be any valid CSS value, for example 768px or 20em"
)
.
needs_reload_ui
(),
"gallery_height"
:
OptionInfo
(
""
,
"Gallery height"
,
gr
.
Textbox
)
.
info
(
"can be any valid CSS value, for example 768px or 20em"
)
.
needs_reload_ui
(),
"open_dir_button_choice"
:
OptionInfo
(
"Subdirectory"
,
"What directory the [📂] button opens"
,
gr
.
Radio
,
{
"choices"
:
[
"Output Root"
,
"Subdirectory"
,
"Subdirectory (even temp dir)"
]}),
}))
}))
options_templates
.
update
(
options_section
((
'ui_alternatives'
,
"UI alternatives"
,
"ui"
),
{
options_templates
.
update
(
options_section
((
'ui_alternatives'
,
"UI alternatives"
,
"ui"
),
{
...
...
modules/ui_common.py
View file @
cb52279c
...
@@ -9,7 +9,7 @@ import sys
...
@@ -9,7 +9,7 @@ import sys
import
gradio
as
gr
import
gradio
as
gr
import
subprocess
as
sp
import
subprocess
as
sp
from
modules
import
call_queue
,
shared
from
modules
import
call_queue
,
shared
,
ui_tempdir
from
modules.infotext_utils
import
image_from_url_text
from
modules.infotext_utils
import
image_from_url_text
import
modules.images
import
modules.images
from
modules.ui_components
import
ToolButton
from
modules.ui_components
import
ToolButton
...
@@ -164,29 +164,43 @@ class OutputPanel:
...
@@ -164,29 +164,43 @@ class OutputPanel:
def
create_output_panel
(
tabname
,
outdir
,
toprow
=
None
):
def
create_output_panel
(
tabname
,
outdir
,
toprow
=
None
):
res
=
OutputPanel
()
res
=
OutputPanel
()
def
open_folder
(
f
):
def
open_folder
(
f
,
images
=
None
,
index
=
None
):
if
shared
.
cmd_opts
.
hide_ui_dir_config
:
return
try
:
if
'Sub'
in
shared
.
opts
.
open_dir_button_choice
:
image_dir
=
os
.
path
.
split
(
images
[
index
][
"name"
]
.
rsplit
(
'?'
,
1
)[
0
])[
0
]
if
'temp'
in
shared
.
opts
.
open_dir_button_choice
or
not
ui_tempdir
.
is_gradio_temp_path
(
image_dir
):
f
=
image_dir
except
Exception
:
pass
if
not
os
.
path
.
exists
(
f
):
if
not
os
.
path
.
exists
(
f
):
print
(
f
'Folder "{f}" does not exist. After you create an image, the folder will be created.'
)
msg
=
f
'Folder "{f}" does not exist. After you create an image, the folder will be created.'
print
(
msg
)
gr
.
Info
(
msg
)
return
return
elif
not
os
.
path
.
isdir
(
f
):
elif
not
os
.
path
.
isdir
(
f
):
print
(
f
"""
msg
=
f
"""
WARNING
WARNING
An open_folder request was made with an argument that is not a folder.
An open_folder request was made with an argument that is not a folder.
This could be an error or a malicious attempt to run code on your computer.
This could be an error or a malicious attempt to run code on your computer.
Requested path was: {f}
Requested path was: {f}
"""
,
file
=
sys
.
stderr
)
"""
print
(
msg
,
file
=
sys
.
stderr
)
gr
.
Warning
(
msg
)
return
return
if
not
shared
.
cmd_opts
.
hide_ui_dir_config
:
path
=
os
.
path
.
normpath
(
f
)
path
=
os
.
path
.
normpath
(
f
)
if
platform
.
system
()
==
"Windows"
:
if
platform
.
system
()
==
"Windows"
:
os
.
startfile
(
path
)
os
.
startfile
(
path
)
elif
platform
.
system
()
==
"Darwin"
:
elif
platform
.
system
()
==
"Darwin"
:
sp
.
Popen
([
"open"
,
path
])
sp
.
Popen
([
"open"
,
path
])
elif
"microsoft-standard-WSL2"
in
platform
.
uname
()
.
release
:
elif
"microsoft-standard-WSL2"
in
platform
.
uname
()
.
release
:
sp
.
Popen
([
"wsl-open"
,
path
])
sp
.
Popen
([
"wsl-open"
,
path
])
else
:
else
:
sp
.
Popen
([
"xdg-open"
,
path
])
sp
.
Popen
([
"xdg-open"
,
path
])
with
gr
.
Column
(
elem_id
=
f
"{tabname}_results"
):
with
gr
.
Column
(
elem_id
=
f
"{tabname}_results"
):
if
toprow
:
if
toprow
:
...
@@ -213,8 +227,12 @@ Requested path was: {f}
...
@@ -213,8 +227,12 @@ Requested path was: {f}
res
.
button_upscale
=
ToolButton
(
'✨'
,
elem_id
=
f
'{tabname}_upscale'
,
tooltip
=
"Create an upscaled version of the current image using hires fix settings."
)
res
.
button_upscale
=
ToolButton
(
'✨'
,
elem_id
=
f
'{tabname}_upscale'
,
tooltip
=
"Create an upscaled version of the current image using hires fix settings."
)
open_folder_button
.
click
(
open_folder_button
.
click
(
fn
=
lambda
:
open_folder
(
shared
.
opts
.
outdir_samples
or
outdir
),
fn
=
lambda
images
,
index
:
open_folder
(
shared
.
opts
.
outdir_samples
or
outdir
,
images
,
index
),
inputs
=
[],
_js
=
"(y, w) => [y, selected_gallery_index()]"
,
inputs
=
[
res
.
gallery
,
open_folder_button
,
# placeholder for index
],
outputs
=
[],
outputs
=
[],
)
)
...
...
modules/ui_tempdir.py
View file @
cb52279c
...
@@ -81,3 +81,18 @@ def cleanup_tmpdr():
...
@@ -81,3 +81,18 @@ def cleanup_tmpdr():
filename
=
os
.
path
.
join
(
root
,
name
)
filename
=
os
.
path
.
join
(
root
,
name
)
os
.
remove
(
filename
)
os
.
remove
(
filename
)
def
is_gradio_temp_path
(
path
):
"""
Check if the path is a temp dir used by gradio
"""
path
=
Path
(
path
)
if
shared
.
opts
.
temp_dir
and
path
.
is_relative_to
(
shared
.
opts
.
temp_dir
):
return
True
if
gradio_temp_dir
:
=
os
.
environ
.
get
(
"GRADIO_TEMP_DIR"
):
if
path
.
is_relative_to
(
gradio_temp_dir
):
return
True
if
path
.
is_relative_to
(
Path
(
tempfile
.
gettempdir
())
/
"gradio"
):
return
True
return
False
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment