1
0
mirror of https://github.com/ihabunek/toot synced 2024-12-25 00:20:55 +01:00

Use context for writing to file

This commit is contained in:
Ivan Habunek 2023-02-02 09:45:36 +01:00
parent 61990822e5
commit c7f9f06f72

View File

@ -42,9 +42,8 @@ class StatusSource(urwid.Padding):
def save_json(self): def save_json(self):
filename = self.filename_edit.get_text()[0][10:] # skip "Filename: " filename = self.filename_edit.get_text()[0][10:] # skip "Filename: "
if filename: if filename:
f = open(filename, "w") with open(filename, "w") as f:
f.write(self.source) f.write(self.source)
f.close()
self.status_text.set_text(("footer_message", f"Saved to {filename}")) self.status_text.set_text(("footer_message", f"Saved to {filename}"))