mirror of
https://github.com/netinvent/npbackup.git
synced 2025-09-11 15:34:57 +08:00
GUI: Avoid scrolling back on msg window every second
This commit is contained in:
parent
887088a351
commit
5a80d545b4
1 changed files with 11 additions and 2 deletions
|
@ -7,7 +7,7 @@ __intname__ = "npbackup.gui.helpers"
|
|||
__author__ = "Orsiris de Jong"
|
||||
__copyright__ = "Copyright (C) 2023-2025 NetInvent"
|
||||
__license__ = "GPL-3.0-only"
|
||||
__build__ = "2025013001"
|
||||
__build__ = "2025030401"
|
||||
|
||||
|
||||
from typing import Tuple, Union
|
||||
|
@ -260,6 +260,8 @@ def gui_thread_runner(
|
|||
|
||||
stdout_cache = ""
|
||||
stderr_cache = ""
|
||||
previous_stdout_cache = ""
|
||||
previous_stderr_cache = ""
|
||||
|
||||
if USE_THREADING:
|
||||
thread = fn(*args, **kwargs)
|
||||
|
@ -330,7 +332,14 @@ def gui_thread_runner(
|
|||
if time.monotonic() - start_time > 1:
|
||||
if len(stdout_cache) > 1000:
|
||||
stdout_cache = stdout_cache[-1000:]
|
||||
_update_gui_from_cache(stdout_cache, stderr_cache)
|
||||
# Don't update GUI if there isn't anything to update so it will avoid scrolling back to top every second
|
||||
if (
|
||||
previous_stdout_cache != stdout_cache
|
||||
or previous_stderr_cache != stderr_cache
|
||||
):
|
||||
_update_gui_from_cache(stdout_cache, stderr_cache)
|
||||
previous_stdout_cache = stdout_cache
|
||||
previous_stderr_cache = stderr_cache
|
||||
start_time = time.monotonic()
|
||||
|
||||
_update_gui_from_cache(stdout_cache, stderr_cache)
|
||||
|
|
Loading…
Add table
Reference in a new issue