Commit da3132a9 authored by Bram Schoenmakers's avatar Bram Schoenmakers

Use signals as they should be used.

Use the emit_signal and register_signal methods to properly set the
signals that CommandLineWidget can emit.
parent 475524d5
......@@ -17,20 +17,19 @@
import urwid
class CommandLineWidget(urwid.Edit):
signals = [
'blur',
'execute_command',
]
def __init__(self, *args, **kwargs):
super(CommandLineWidget, self).__init__(*args, **kwargs)
urwid.register_signal(CommandLineWidget, ['blur', 'execute_command'])
def clear(self):
self.set_edit_text(u"")
def _blur(self):
self.clear()
self._emit('blur')
urwid.emit_signal(self, 'blur')
def _emit_command(self):
self._emit('execute_command', self.edit_text)
urwid.emit_signal(self, 'execute_command', self.edit_text)
self.clear()
def keypress(self, p_size, p_key):
......
......@@ -34,7 +34,7 @@ class UIApplication(CLIApplicationBase):
self.columns = urwid.Columns([], dividechars=0, min_width=COLUMN_WIDTH)
self.commandline = CommandLineWidget('topydo> ')
urwid.connect_signal(self.commandline, 'blur',
lambda _: self._blur_commandline())
self._blur_commandline)
urwid.connect_signal(self.commandline, 'execute_command',
self._execute_input)
......@@ -52,7 +52,7 @@ class UIApplication(CLIApplicationBase):
pop_ups=True
)
def _execute_input(self, _, p_command):
def _execute_input(self, p_command):
"""
Callback for executing a command that was entered on the command line box.
"""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment