Skip to content

Delay needed when loading a script #480

@willbelr

Description

@willbelr

A rendering problem affects 'graphics' terminal programs such as top and htop when they are launched using a script. A workaround consists in adding a short delay at the head of the script.

Expected Behavior

Correct rendering

Current Behavior

Incorrect rendering

Possible Solution

Not sure how it is handled in C++, but in PyQt sometimes this type of problem is caused by a premature function call somewhere, which can be delayed until next loop with QtCore.QTimer.singleShot(0, function)

Steps to Reproduce

Exemple code below. As shown, by adding sleep 0.1 && the problem is fixed.

#!/usr/bin/python3
import sys
from PyQt5 import QtWidgets
from QTermWidget import QTermWidget

with open("/tmp/test.sh", "w") as f:
    # f.write("sleep 0.1 && htop")  # good
    f.write("htop")  # bad


app = QtWidgets.QApplication(sys.argv)
term = QTermWidget(0)
term.setColorScheme("DarkPastels")
term.setShellProgram("/bin/bash")
term.setArgs(["/tmp/test.sh"])
term.startShellProgram()
term.show()
app.exec()
System Information
  • Distribution & Version: Arch
  • Kernel: 5.15.32-1-lts SMP Mon, 28 Mar 2022 08:54:31 +0000 x86_64 GNU/Linux
  • Qt Version: 5.15.3
  • lxqt-build-tools Version: 0.10.0-1
  • Package version: 1.0.0-2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions