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 @@ ...@@ -17,20 +17,19 @@
import urwid import urwid
class CommandLineWidget(urwid.Edit): class CommandLineWidget(urwid.Edit):
signals = [ def __init__(self, *args, **kwargs):
'blur', super(CommandLineWidget, self).__init__(*args, **kwargs)
'execute_command', urwid.register_signal(CommandLineWidget, ['blur', 'execute_command'])
]
def clear(self): def clear(self):
self.set_edit_text(u"") self.set_edit_text(u"")
def _blur(self): def _blur(self):
self.clear() self.clear()
self._emit('blur') urwid.emit_signal(self, 'blur')
def _emit_command(self): def _emit_command(self):
self._emit('execute_command', self.edit_text) urwid.emit_signal(self, 'execute_command', self.edit_text)
self.clear() self.clear()
def keypress(self, p_size, p_key): def keypress(self, p_size, p_key):
......
...@@ -34,7 +34,7 @@ class UIApplication(CLIApplicationBase): ...@@ -34,7 +34,7 @@ class UIApplication(CLIApplicationBase):
self.columns = urwid.Columns([], dividechars=0, min_width=COLUMN_WIDTH) self.columns = urwid.Columns([], dividechars=0, min_width=COLUMN_WIDTH)
self.commandline = CommandLineWidget('topydo> ') self.commandline = CommandLineWidget('topydo> ')
urwid.connect_signal(self.commandline, 'blur', urwid.connect_signal(self.commandline, 'blur',
lambda _: self._blur_commandline()) self._blur_commandline)
urwid.connect_signal(self.commandline, 'execute_command', urwid.connect_signal(self.commandline, 'execute_command',
self._execute_input) self._execute_input)
...@@ -52,7 +52,7 @@ class UIApplication(CLIApplicationBase): ...@@ -52,7 +52,7 @@ class UIApplication(CLIApplicationBase):
pop_ups=True 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. 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