mirror of
https://github.com/Textualize/textual-serve.git
synced 2025-10-17 02:50:37 +03:00
Using IO objects
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import io
|
||||
from textual import on
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.binding import Binding
|
||||
@@ -15,8 +16,10 @@ class ScreenshotApp(App[None]):
|
||||
self.action_deliver_screenshot()
|
||||
|
||||
def action_deliver_screenshot(self) -> None:
|
||||
filename = self.save_screenshot("screenshot.svg")
|
||||
self.deliver_text(filename)
|
||||
screenshot_string = self.export_screenshot()
|
||||
string_io = io.StringIO(screenshot_string)
|
||||
print(isinstance(string_io, io.TextIOBase))
|
||||
self.deliver_text(string_io)
|
||||
|
||||
|
||||
app = ScreenshotApp()
|
||||
|
||||
@@ -9,9 +9,9 @@ dependencies = [
|
||||
"aiohttp>=3.9.5",
|
||||
"aiohttp-jinja2>=1.6",
|
||||
"jinja2>=3.1.4",
|
||||
"textual>=0.66.0",
|
||||
"msgpack>=1.0.8",
|
||||
"rich",
|
||||
"textual[syntax] @ file:///Users/darrenburns/code/textual-serve/../textual",
|
||||
]
|
||||
readme = "README.md"
|
||||
requires-python = ">= 3.8"
|
||||
|
||||
@@ -58,12 +58,15 @@ mdit-py-plugins==0.4.1
|
||||
mdurl==0.1.2
|
||||
# via markdown-it-py
|
||||
msgpack==1.0.8
|
||||
# via textual
|
||||
# via textual-dev
|
||||
# via textual-serve
|
||||
msgpack-types==0.3.0
|
||||
multidict==6.0.5
|
||||
# via aiohttp
|
||||
# via yarl
|
||||
platformdirs==4.2.2
|
||||
# via textual
|
||||
pygments==2.18.0
|
||||
# via rich
|
||||
rich==13.7.1
|
||||
@@ -72,10 +75,15 @@ rich==13.7.1
|
||||
sniffio==1.3.1
|
||||
# via anyio
|
||||
# via httpx
|
||||
textual==0.76.0
|
||||
textual @ file:///Users/darrenburns/code/textual-serve/../textual
|
||||
# via textual-dev
|
||||
# via textual-serve
|
||||
textual-dev==1.5.1
|
||||
tree-sitter==0.20.4
|
||||
# via textual
|
||||
# via tree-sitter-languages
|
||||
tree-sitter-languages==1.10.2
|
||||
# via textual
|
||||
typing-extensions==4.12.2
|
||||
# via anyio
|
||||
# via rich
|
||||
|
||||
@@ -41,17 +41,25 @@ mdit-py-plugins==0.4.1
|
||||
mdurl==0.1.2
|
||||
# via markdown-it-py
|
||||
msgpack==1.0.8
|
||||
# via textual
|
||||
# via textual-serve
|
||||
multidict==6.0.5
|
||||
# via aiohttp
|
||||
# via yarl
|
||||
platformdirs==4.2.2
|
||||
# via textual
|
||||
pygments==2.18.0
|
||||
# via rich
|
||||
rich==13.7.1
|
||||
# via textual
|
||||
# via textual-serve
|
||||
textual==0.76.0
|
||||
textual @ file:///Users/darrenburns/code/textual-serve/../textual
|
||||
# via textual-serve
|
||||
tree-sitter==0.20.4
|
||||
# via textual
|
||||
# via tree-sitter-languages
|
||||
tree-sitter-languages==1.10.2
|
||||
# via textual
|
||||
typing-extensions==4.12.2
|
||||
# via rich
|
||||
# via textual
|
||||
|
||||
@@ -22,6 +22,9 @@ class Download:
|
||||
open_method: str
|
||||
mime_type: str
|
||||
encoding: str | None = None
|
||||
"""The encoding of the content.
|
||||
Will be None if the content is binary.
|
||||
"""
|
||||
incoming_chunks: asyncio.Queue[bytes | None] = field(default_factory=asyncio.Queue)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user