Add output folder icons

Handling of the --hide-ui-dir-config flag and added multi-platform code for opening a folder
This commit is contained in:
Michoko 2022-09-28 10:31:53 +02:00 committed by AUTOMATIC1111
parent f8acbb8f88
commit 02c4b757b6
2 changed files with 20 additions and 4 deletions

View File

@ -9,6 +9,8 @@ import random
import sys
import time
import traceback
import platform
import subprocess as sp
import numpy as np
import torch
@ -461,7 +463,8 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo, run_modelmerger):
send_to_img2img = gr.Button('Send to img2img')
send_to_inpaint = gr.Button('Send to inpaint')
send_to_extras = gr.Button('Send to extras')
open_txt2img_folder = gr.Button(folder_symbol, elem_id="open_folder")
button_id = "open_folder_hidden" if shared.cmd_opts.hide_ui_dir_config else 'open_folder'
open_txt2img_folder = gr.Button(folder_symbol, elem_id=button_id)
with gr.Group():
html_info = gr.HTML()
@ -638,7 +641,8 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo, run_modelmerger):
img2img_send_to_img2img = gr.Button('Send to img2img')
img2img_send_to_inpaint = gr.Button('Send to inpaint')
img2img_send_to_extras = gr.Button('Send to extras')
open_img2img_folder = gr.Button(folder_symbol, elem_id="open_folder")
button_id = "open_folder_hidden" if shared.cmd_opts.hide_ui_dir_config else 'open_folder'
open_img2img_folder = gr.Button(folder_symbol, elem_id=button_id)
with gr.Group():
html_info = gr.HTML()
@ -811,7 +815,8 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo, run_modelmerger):
html_info = gr.HTML()
extras_send_to_img2img = gr.Button('Send to img2img')
extras_send_to_inpaint = gr.Button('Send to inpaint')
open_extras_folder = gr.Button('Open output directory')
button_id = "open_folder_hidden" if shared.cmd_opts.hide_ui_dir_config else ''
open_extras_folder = gr.Button('Open output directory', elem_id=button_id)
submit.click(
fn=run_extras,
@ -911,7 +916,14 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo, run_modelmerger):
component_dict = {}
def open_folder(f):
os.startfile(os.path.normpath(f))
if not shared.cmd_opts.hide_ui_dir_config:
path = os.path.normpath(f)
if platform.system() == "Windows":
os.startfile(path)
elif platform.system() == "Darwin":
sp.Popen(["open", path])
else:
sp.Popen(["xdg-open", path])
def run_settings(*args):
changed = 0

View File

@ -56,6 +56,10 @@
padding-right: 0.25em;
}
#open_folder_hidden{
display: none;
}
#seed_row, #subseed_row{
gap: 0.5rem;
}