Comments (14)
The sequence actually comes from your terminal! Basically, PTG writes a pixel dimension request, and the terminal has some time (I think 0.1 seconds) to respond. The timing is there to solve an issue where PTG would try to catch sequences that are never written, so it would just get stuck on an endless getch
call.
The sensible thing to do here would be the only query the dimensions on demand, so it's not done when not needed. The timeout could also be a bit larger.
from pytermgui.
Aw heck. The sequence is the response to use querying the terminal's foreground color, which we need to create an accurate screenshot. Gonna try to look into why the response doesn't get captured.
from pytermgui.
That's alright! Let me know if you ever run into it again.
from pytermgui.
I see, thanks for the explanation 🙂
I'd be totally fine with being able to configure the timeout through an env var if this is something you'd consider.
from pytermgui.
Could you check on the latest commit? This should be fixed now.
from pytermgui.
Just checked (pip install using master branch, i.e. commit e523f70): seems to be fixed indeed! Thanks!
from pytermgui.
Hello, I'm having a similar issue again. When I run the following snippet in a subprocess, it prints an ANSI sequence and then gets stuck:
from io import StringIO
import pytermgui as ptg
terminal = ptg.Terminal(stream=StringIO(), size=(80, 16))
ptg.set_global_terminal(terminal)
with terminal.record() as recorder:
recorder.write(ptg.tim.parse(ptg.highlight_python(code)))
print("before svg")
svg = recorder.export_svg(inline_styles=True)
print("after svg")
Output when running it:
before svg
^[]10;rgb:e4e4/d9d9/c6c6^G
Note that this happens in a mkdocs
subprocess, and then in an exec
call (I'm working on markdown-exec 😉). Not sure if it really matters.
Do you know to what corresponds this ANSI sequence ^[]10;rgb:e4e4/d9d9/c6c6^G
? (and why it's printed on screen?)
from pytermgui.
Hey, is this still an issue? I'm not sure if anything related has changed since then, but in case things are still broken I can look into it.
from pytermgui.
Let me check, I had disabled pytermgui in the meantime :)
from pytermgui.
Still happens, but only when I run the mkdocs command through my task runner (duty) it seems (didn't test extensively), so don't bother too much. I'll try to isolate the real cause when I get some time 🙂
from pytermgui.
Ever figure it out? :)
from pytermgui.
Nope, sorry 😕
from pytermgui.
So it's still happening. The crux of the issue is probably that I'm capturing the output, preventing PyTermGUI to read it it itself when querying the terminal for the foreground color, so it blocks. The sequence I'm seeing: ^[]11;rgb:1212/1919/0d0d^[\
. I'm capturing output at the file descriptor level: https://github.com/pawamoy/failprint/blob/3d1317dc9f663719bab381c1f39fe54cda308d3f/src/failprint/capture.py#L78.
Ideally, PyTermGUI wouldn't block thanks to a read timeout or something 🙂 I'm trying to think of something for disabling it when capturing the output (when I'm checking if the docs build correctly), but I don't see yet how I could disable just a paragraph in one my Markdown pages 🤔
from pytermgui.
OK found a workaround, I'm adding this at the top of the PyTermGUI snippet:
import os # markdown-exec: hide
for envvar in ("PYTHON_VERSIONS", "CI", "MULTIRUN"): # markdown-exec: hide
if envvar in os.environ: # markdown-exec: hide
print( # markdown-exec: hide
"PyTermGUI blocks when querying the terminal foreground color with an ANSI sequence " # markdown-exec: hide
"because we capture the output ourselves through `failprint`, " # markdown-exec: hide
"so this gallery example is disabled in CI.", # markdown-exec: hide
) # markdown-exec: hide
raise SystemExit(0) # markdown-exec: hide
from pytermgui.
Related Issues (20)
- [BUG] Long unicode (emojis) get wrong length calculated HOT 1
- Enter doesn't activate buttons HOT 1
- Windows compatibility and example apps HOT 13
- tutorial HOT 10
- [REQUEST] Python 3.8 HOT 2
- [BUG] Cannot delete text in InputField HOT 11
- [BUG] [WSL2] XTerm does not display "box drawing" characters (but other terminals do) HOT 1
- [BUG] Inline widget: Mouse report event 'hover' is not supported HOT 1
- No documentation available HOT 4
- Question regarding `ptg.InputField` HOT 5
- How do I update the values screen HOT 1
- [HOWTO] How can I use the terminal widget? HOT 2
- Official Debian package HOT 1
- [REQUEST] Include pyproject.toml in pip package
- [BUG] Multiline InputField fails to display correctly a in scrollable container
- [BUG] All colors are mapped wrong on Windows when styling
- [REQUEST] WindowManager.add unexpected behvaiour with slot names
- [REQUEST] Browsing between selectables does not trigger scroll
- DOC - Documentations issues/findings
- [BUG] Cursor Movement is broken in InputField HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pytermgui.