mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
fix for point key and keys in screenshot
This commit is contained in:
@@ -2,4 +2,7 @@
|
||||
|
||||
{% block extrahead %}
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/fira_code.min.css" integrity="sha512-MbysAYimH1hH2xYzkkMHB6MqxBqfP0megxsCLknbYqHVwXTCg9IqHbk+ZP/vnhO8UEW6PaXAkKe2vQ+SWACxxA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
||||
<!-- Fathom - beautiful, simple website analytics -->
|
||||
<script src="https://cdn.usefathom.com/script.js" data-site="TAUKXRLQ" defer></script>
|
||||
<!-- / Fathom -->
|
||||
{% endblock %}
|
||||
|
||||
@@ -24,6 +24,7 @@ class CalculatorApp(App):
|
||||
"asterisk": "multiply",
|
||||
"slash": "divide",
|
||||
"underscore": "plus-minus",
|
||||
"full_stop": "point",
|
||||
"plus_minus_sign": "plus-minus",
|
||||
"percent_sign": "percent",
|
||||
"equals_sign": "equals",
|
||||
|
||||
@@ -612,6 +612,13 @@ class App(Generic[ReturnType], DOMNode):
|
||||
print(f"(pause {wait_ms}ms)")
|
||||
await asyncio.sleep(float(wait_ms) / 1000)
|
||||
else:
|
||||
if len(key) == 1 and not key.isalnum():
|
||||
key = (
|
||||
unicodedata.name(key)
|
||||
.lower()
|
||||
.replace("-", "_")
|
||||
.replace(" ", "_")
|
||||
)
|
||||
original_key = REPLACED_KEYS.get(key, key)
|
||||
try:
|
||||
char = unicodedata.lookup(
|
||||
@@ -620,7 +627,8 @@ class App(Generic[ReturnType], DOMNode):
|
||||
except KeyError:
|
||||
char = key if len(key) == 1 else None
|
||||
print(f"press {key!r} (char={char!r})")
|
||||
driver.send_event(events.Key(self, key, char))
|
||||
key_event = events.Key(self, key, char)
|
||||
driver.send_event(key_event)
|
||||
await asyncio.sleep(0.01)
|
||||
|
||||
await app._animator.wait_for_idle()
|
||||
|
||||
Reference in New Issue
Block a user