1
0
mirror of https://github.com/ihabunek/toot synced 2024-12-23 23:52:40 +01:00

Inline button construction, avoid lambda

This commit is contained in:
Ivan Habunek 2023-02-02 09:25:55 +01:00
parent c7f9f06f72
commit 1b2da81d15

View File

@ -19,11 +19,8 @@ class StatusSource(urwid.Padding):
])
list = urwid.ListBox(walker)
def save_button(title):
return Button(title, on_press=lambda btn: self.save_json())
self.filename_edit = EditBox(caption="Filename: ", edit_text="status.json")
self.save_button = save_button("Save")
self.save_button = Button("Save", on_press=self.save_json)
self.status_text = urwid.Text("")
frame = urwid.Frame(
@ -39,7 +36,7 @@ class StatusSource(urwid.Padding):
)
super().__init__(frame)
def save_json(self):
def save_json(self, button):
filename = self.filename_edit.get_text()[0][10:] # skip "Filename: "
if filename:
with open(filename, "w") as f: