Xterm.js Terminal Display Element Example #1846
Replies: 4 comments 8 replies
-
Sorry for noob question, but I have zero knowledge in JS. Where do I get xterm.js and xterm.css files? I downloaded github repo https://github.com/xtermjs/xterm.js, but these files are absent. |
Beta Was this translation helpful? Give feedback.
-
I updated the original post with better instructions and some better structured code since it appears there was some interest. |
Beta Was this translation helpful? Give feedback.
-
Very nice, @natankeddem! I'm also not sure if there's demand for xterm as a built-in NiceGUI element. Isn't it similar to As a side note: I'm currently struggling with a leaflet integration (see PR #1217), which also comes with both JavaScript and CSS files. Getting a proof of concept up and running is always relatively easy thanks to |
Beta Was this translation helpful? Give feedback.
-
I am continuing to work with this, and exercise it in some various situations. I did find a strange issue, and I am not really sure how to diagnose what is going on. What exactly does using with ui.row() as row:
row.tailwind.align_items("center")
cmd = ui.input("Command", value="curl --limit-rate 1k -O http://speedtest.ftp.otenet.gr/files/test100k.db")
cmd.tailwind.width("[480px]")
run = ui.button("run", on_click=execute)
ui.button("show last", on_click=show_last).bind_enabled_from(run, "enabled")
ui.button("clear", on_click=lambda _: terminal.call_terminal_method("reset")).bind_enabled_from(run, "enabled")
ui.button("terminate", on_click=cli.terminate)
terminal = el.Terminal(options={"rows": 30, "cols": 120, "convertEol": True}) Now I encapsulate the same exact layout in @ui.page("/")
def page_layout():
with ui.row() as row:
row.tailwind.align_items("center")
cmd = ui.input("Command", value="curl --limit-rate 1k -O http://speedtest.ftp.otenet.gr/files/test100k.db")
cmd.tailwind.width("[480px]")
run = ui.button("run", on_click=execute)
ui.button("show last", on_click=show_last).bind_enabled_from(run, "enabled")
ui.button("clear", on_click=lambda _: terminal.call_terminal_method("reset")).bind_enabled_from(run, "enabled")
ui.button("terminate", on_click=cli.terminate)
terminal = el.Terminal(options={"rows": 30, "cols": 120, "convertEol": True}) I see no obvious errors in the python console or browser console. I understand I didn't give a fully executable example here but if you want to piece it together with my original post you can recreate my issue I think. I am hoping there is something obvious I missed in my setup which would cause this. |
Beta Was this translation helpful? Give feedback.
-
I am working on this for possible usage in a project. I don't know if there is much interest in this sort of element, and there are already so many, I know there is concern over the current bloat of libraries. Let me know if anyone wants me to make this a built in element or make a formal example. In any case this discussion can be used to reference integrating a random third-party JS library into a project and some
asyncio
interactions.google_screen_recording_2023-10-20T15-55_08.310Z.webm
Here is the quick and dirty code:
terminal.js
You can get
xterm.js
andxterm.css
from npm or a CDN like this:https://cdn.jsdelivr.net/npm/[email protected]/
Then stick all the
js
andcss
files in a folder calledstatic
in the root of the project.Beta Was this translation helpful? Give feedback.
All reactions