Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
topydo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
topydo
Commits
ed719b62
Commit
ed719b62
authored
Jan 26, 2016
by
Bram Schoenmakers
Committed by
Jacek Sowiński
Feb 11, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass a callback function to the alarm instead of PendingAction object
parent
02529bdf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
35 deletions
+12
-35
topydo/ui/Main.py
topydo/ui/Main.py
+4
-11
topydo/ui/TodoListWidget.py
topydo/ui/TodoListWidget.py
+8
-24
No files found.
topydo/ui/Main.py
View file @
ed719b62
...
@@ -324,19 +324,12 @@ class UIApplication(CLIApplicationBase):
...
@@ -324,19 +324,12 @@ class UIApplication(CLIApplicationBase):
self
.
columns
.
focus_position
=
p_pos
self
.
columns
.
focus_position
=
p_pos
self
.
_blur_commandline
()
self
.
_blur_commandline
()
def
_set_alarm
(
self
,
p_action
):
def
_set_alarm
(
self
,
p_callback
):
"""
""" Sets alarm to execute p_action specified in 0.5 sec. """
Sets alarm to execute p_action specified in 0.5 sec.
self
.
_alarm
=
self
.
mainloop
.
set_alarm_in
(
0.5
,
p_callback
)
Handle for this alarm is stored as _alarm attribute.
p_action must be an object with 'execute' method.
"""
self
.
_alarm
=
self
.
mainloop
.
set_alarm_in
(
0.5
,
p_action
.
execute
)
def
_remove_alarm
(
self
):
def
_remove_alarm
(
self
):
"""
""" Removes pending action alarm stored in _alarm attribute. """
Removes pending action alarm stored in _alarm attribute.
"""
self
.
mainloop
.
remove_alarm
(
self
.
_alarm
)
self
.
mainloop
.
remove_alarm
(
self
.
_alarm
)
self
.
_alarm
=
None
self
.
_alarm
=
None
...
...
topydo/ui/TodoListWidget.py
View file @
ed719b62
...
@@ -29,27 +29,6 @@ def get_execute_signal(p_prefix):
...
@@ -29,27 +29,6 @@ def get_execute_signal(p_prefix):
return
signal
return
signal
class
PendingAction
(
object
):
"""
Object class for storing TodoListWidget action waiting for execution.
"""
def
__init__
(
self
,
p_tlw
,
p_action_str
,
p_size
):
self
.
todolist
=
p_tlw
self
.
action_str
=
p_action_str
self
.
size
=
p_size
def
execute
(
self
,
p_loop
,
p_user_data
=
None
):
"""
Executes action stored in action_str attribute from within p_loop
(typically urwid.MainLoop).
Since this method is primarily used as callback for
urwid.MainLoop.set_alarm_in it has to accept 3rd parameter: p_user_data.
"""
self
.
todolist
.
resolve_action
(
self
.
action_str
,
self
.
size
)
self
.
todolist
.
keystate
=
None
class
TodoListWidget
(
urwid
.
LineBox
):
class
TodoListWidget
(
urwid
.
LineBox
):
def
__init__
(
self
,
p_view
,
p_title
,
p_keymap
):
def
__init__
(
self
,
p_view
,
p_title
,
p_keymap
):
self
.
_view
=
None
self
.
_view
=
None
...
@@ -288,9 +267,14 @@ class TodoListWidget(urwid.LineBox):
...
@@ -288,9 +267,14 @@ class TodoListWidget(urwid.LineBox):
"""
"""
Creates action waiting for execution and forwards it to the mainloop.
Creates action waiting for execution and forwards it to the mainloop.
"""
"""
urwid
.
emit_signal
(
self
,
'add_pending_action'
,
PendingAction
(
self
,
def
generate_callback
():
p_action
,
def
callback
(
*
args
):
p_size
))
self
.
resolve_action
(
p_action
,
p_size
)
self
.
keystate
=
None
return
callback
urwid
.
emit_signal
(
self
,
'add_pending_action'
,
generate_callback
())
def
_postpone_selected
(
self
,
p_pattern
,
p_mode
):
def
_postpone_selected
(
self
,
p_pattern
,
p_mode
):
"""
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment