fix devtools run

This commit is contained in:
Will McGugan
2022-09-01 20:17:47 +01:00
parent 278b8485e6
commit e51ebab345
2 changed files with 5 additions and 7 deletions

View File

@@ -130,7 +130,7 @@ class BasicApp(App, css_path="basic.css"):
classes="scrollable",
),
table,
Widget(DirectoryTree("~/projects/textual"), id="tree-container"),
Widget(DirectoryTree("~/"), id="tree-container"),
Error(),
Tweet(TweetBody(), classes="scrollbar-size-custom"),
Warning(),

View File

@@ -1,5 +1,7 @@
from __future__ import annotations
import os
import runpy
from typing import cast, TYPE_CHECKING
from importlib_metadata import version
@@ -57,16 +59,12 @@ def import_app(import_name: str) -> App:
lib, _colon, name = import_name.partition(":")
if lib.endswith(".py"):
# We're assuming the user wants to load a .py file
path = os.path.abspath(lib)
try:
with open(lib) as python_file:
py_code = python_file.read()
global_vars = runpy.run_path(path)
except Exception as error:
raise AppFail(str(error))
global_vars: dict[str, object] = {}
exec(py_code, global_vars)
if name:
# User has given a name, use that
try: