Skip to content

Commit

Permalink
textual 0.11 support
Browse files Browse the repository at this point in the history
  • Loading branch information
agmmnn committed Feb 17, 2023
1 parent 95a4784 commit cd55772
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion examples/hidden.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def on_file_drop_dropped(self, event: FileDrop.Dropped) -> None:
filenames = event.filenames
filesobj = event.filesobj

with open(filepaths[0], "r") as f:
with open(filepaths[0], "r", encoding="utf-8") as f:
self.query_one("#title").update(filenames[0])
self.query_one("#content").update(f.read())

Expand Down
7 changes: 4 additions & 3 deletions examples/subdomain_lister.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from textual.app import App, ComposeResult
from textual.containers import Vertical, Horizontal, Container
from textual.widgets import Static, Button, Input, Tree, TreeNode
from textual.containers import Horizontal
from textual.widgets import Static, Tree
from textual.widgets.tree import TreeNode
from rich.text import Text

import tldextract
Expand Down Expand Up @@ -42,7 +43,7 @@ def on_file_drop_dropped(self, event: FileDrop.Dropped) -> None:
subs = []
for i in filepaths:
try:
with open(i, "r") as f:
with open(i, "r", encoding="utf-8") as f:
contents = f.read()
subs.extend(filter(lambda x: x != "", contents.split("\n")))
except:
Expand Down
8 changes: 4 additions & 4 deletions textual_filedrop/_filedrop.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ class FileDrop(Widget, can_focus=True, can_focus_children=False):
def __init__(
self,
display: bool = True,
name: str | None = None,
id: str | None = None,
classes: str | None = None,
name: str = None,
id: str = None,
classes: str = None,
) -> None:
super().__init__(name=name, id=id, classes=classes)

Expand Down Expand Up @@ -86,7 +86,7 @@ async def on_event(self, event: events.Event) -> None:
"icon": get_icon(file_name, file_ext),
}
)
await self.emit(
await self.post_message(
self.Dropped(
self,
os.path.split(filepaths[0])[0],
Expand Down

0 comments on commit cd55772

Please sign in to comment.