mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
user must adjust terminal size on Windows
This commit is contained in:
parent
72c891bbac
commit
b767b5d44c
@ -629,7 +629,7 @@ def run_console_ui(
|
||||
|
||||
# The third argument is needed in the Windows 11 environment to
|
||||
# launch a console window running this program.
|
||||
set_min_terminal_size(MIN_COLS, MIN_LINES,'invokeai-configure')
|
||||
set_min_terminal_size(MIN_COLS, MIN_LINES)
|
||||
|
||||
# the install-models application spawns a subprocess to install
|
||||
# models, and will crash unless this is set before running.
|
||||
|
@ -701,7 +701,7 @@ def select_and_download_models(opt: Namespace):
|
||||
|
||||
# the third argument is needed in the Windows 11 environment in
|
||||
# order to launch and resize a console window running this program
|
||||
set_min_terminal_size(MIN_COLS, MIN_LINES,'invokeai-model-install')
|
||||
set_min_terminal_size(MIN_COLS, MIN_LINES)
|
||||
installApp = AddModelApplication(opt)
|
||||
try:
|
||||
installApp.run()
|
||||
|
@ -17,18 +17,20 @@ from shutil import get_terminal_size
|
||||
from curses import BUTTON2_CLICKED,BUTTON3_CLICKED
|
||||
|
||||
# minimum size for UIs
|
||||
MIN_COLS = 130
|
||||
MIN_COLS = 136
|
||||
MIN_LINES = 45
|
||||
|
||||
# -------------------------------------
|
||||
def set_terminal_size(columns: int, lines: int, launch_command: str=None):
|
||||
def set_terminal_size(columns: int, lines: int):
|
||||
ts = get_terminal_size()
|
||||
width = max(columns,ts.columns)
|
||||
height = max(lines,ts.lines)
|
||||
|
||||
OS = platform.uname().system
|
||||
if OS == "Windows":
|
||||
_set_terminal_size_powershell(width,height)
|
||||
pass
|
||||
# not working reliably - ask user to adjust the window
|
||||
#_set_terminal_size_powershell(width,height)
|
||||
elif OS in ["Darwin", "Linux"]:
|
||||
_set_terminal_size_unix(width,height)
|
||||
|
||||
@ -74,20 +76,14 @@ def _set_terminal_size_unix(width: int, height: int):
|
||||
sys.stdout.write("\x1b[8;{height};{width}t".format(height=height, width=width))
|
||||
sys.stdout.flush()
|
||||
|
||||
def set_min_terminal_size(min_cols: int, min_lines: int, launch_command: str=None):
|
||||
def set_min_terminal_size(min_cols: int, min_lines: int):
|
||||
# make sure there's enough room for the ui
|
||||
term_cols, term_lines = get_terminal_size()
|
||||
if term_cols >= min_cols and term_lines >= min_lines:
|
||||
return
|
||||
cols = max(term_cols, min_cols)
|
||||
lines = max(term_lines, min_lines)
|
||||
set_terminal_size(cols, lines, launch_command)
|
||||
|
||||
# did it work?
|
||||
term_cols, term_lines = get_terminal_size()
|
||||
if term_cols < cols or term_lines < lines:
|
||||
print(f'This window is too small for optimal display. For best results please enlarge it.')
|
||||
input('After resizing, press any key to continue...')
|
||||
set_terminal_size(cols, lines)
|
||||
|
||||
class IntSlider(npyscreen.Slider):
|
||||
def translate_value(self):
|
||||
|
Loading…
Reference in New Issue
Block a user