mirror of
https://github.com/ihabunek/toot.git
synced 2024-11-03 04:17:21 -05:00
Inline button construction, avoid lambda
This commit is contained in:
parent
c7f9f06f72
commit
1b2da81d15
@ -19,11 +19,8 @@ class StatusSource(urwid.Padding):
|
|||||||
])
|
])
|
||||||
list = urwid.ListBox(walker)
|
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.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("")
|
self.status_text = urwid.Text("")
|
||||||
|
|
||||||
frame = urwid.Frame(
|
frame = urwid.Frame(
|
||||||
@ -39,7 +36,7 @@ class StatusSource(urwid.Padding):
|
|||||||
)
|
)
|
||||||
super().__init__(frame)
|
super().__init__(frame)
|
||||||
|
|
||||||
def save_json(self):
|
def save_json(self, button):
|
||||||
filename = self.filename_edit.get_text()[0][10:] # skip "Filename: "
|
filename = self.filename_edit.get_text()[0][10:] # skip "Filename: "
|
||||||
if filename:
|
if filename:
|
||||||
with open(filename, "w") as f:
|
with open(filename, "w") as f:
|
||||||
|
Loading…
Reference in New Issue
Block a user