mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
fix devtools run
This commit is contained in:
@@ -130,7 +130,7 @@ class BasicApp(App, css_path="basic.css"):
|
|||||||
classes="scrollable",
|
classes="scrollable",
|
||||||
),
|
),
|
||||||
table,
|
table,
|
||||||
Widget(DirectoryTree("~/projects/textual"), id="tree-container"),
|
Widget(DirectoryTree("~/"), id="tree-container"),
|
||||||
Error(),
|
Error(),
|
||||||
Tweet(TweetBody(), classes="scrollbar-size-custom"),
|
Tweet(TweetBody(), classes="scrollbar-size-custom"),
|
||||||
Warning(),
|
Warning(),
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import os
|
||||||
|
import runpy
|
||||||
from typing import cast, TYPE_CHECKING
|
from typing import cast, TYPE_CHECKING
|
||||||
|
|
||||||
from importlib_metadata import version
|
from importlib_metadata import version
|
||||||
@@ -57,16 +59,12 @@ def import_app(import_name: str) -> App:
|
|||||||
lib, _colon, name = import_name.partition(":")
|
lib, _colon, name = import_name.partition(":")
|
||||||
|
|
||||||
if lib.endswith(".py"):
|
if lib.endswith(".py"):
|
||||||
# We're assuming the user wants to load a .py file
|
path = os.path.abspath(lib)
|
||||||
try:
|
try:
|
||||||
with open(lib) as python_file:
|
global_vars = runpy.run_path(path)
|
||||||
py_code = python_file.read()
|
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
raise AppFail(str(error))
|
raise AppFail(str(error))
|
||||||
|
|
||||||
global_vars: dict[str, object] = {}
|
|
||||||
exec(py_code, global_vars)
|
|
||||||
|
|
||||||
if name:
|
if name:
|
||||||
# User has given a name, use that
|
# User has given a name, use that
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user