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
ca7f7cf4
Commit
ca7f7cf4
authored
Jun 12, 2015
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show output and errors of the commands in a new console widget.
parent
da3132a9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
2 deletions
+66
-2
topydo/ui/ConsoleWidget.py
topydo/ui/ConsoleWidget.py
+39
-0
topydo/ui/Main.py
topydo/ui/Main.py
+27
-2
No files found.
topydo/ui/ConsoleWidget.py
0 → 100644
View file @
ca7f7cf4
# Topydo - A todo.txt client written in Python.
# Copyright (C) 2015 Bram Schoenmakers <me@bramschoenmakers.nl>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import
urwid
class
ConsoleWidget
(
urwid
.
LineBox
):
def
__init__
(
self
,
p_text
=
""
):
urwid
.
register_signal
(
ConsoleWidget
,
[
'close'
])
self
.
text
=
urwid
.
Text
(
p_text
)
super
(
ConsoleWidget
,
self
).
__init__
(
self
.
text
)
def
keypress
(
self
,
p_size
,
p_key
):
if
p_key
==
'enter'
or
p_key
==
'q'
or
p_key
==
'esc'
:
urwid
.
emit_signal
(
self
,
'close'
)
# don't return the key, 'enter', 'escape' or 'q' are your only escape.
def
selectable
(
self
):
return
True
def
print_text
(
self
,
p_text
):
self
.
text
.
set_text
(
self
.
text
.
text
+
p_text
)
def
clear
(
self
):
self
.
text
.
set_text
(
""
)
topydo/ui/Main.py
View file @
ca7f7cf4
...
...
@@ -19,6 +19,7 @@ import urwid
from
topydo.cli.CLIApplicationBase
import
CLIApplicationBase
from
topydo.Commands
import
get_subcommand
from
topydo.ui.CommandLineWidget
import
CommandLineWidget
from
topydo.ui.ConsoleWidget
import
ConsoleWidget
from
topydo.ui.TodoListWidget
import
TodoListWidget
from
topydo.lib.Config
import
config
from
topydo.lib.Sorter
import
Sorter
...
...
@@ -33,10 +34,13 @@ class UIApplication(CLIApplicationBase):
self
.
columns
=
urwid
.
Columns
([],
dividechars
=
0
,
min_width
=
COLUMN_WIDTH
)
self
.
commandline
=
CommandLineWidget
(
'topydo> '
)
self
.
console
=
ConsoleWidget
()
urwid
.
connect_signal
(
self
.
commandline
,
'blur'
,
self
.
_blur_commandline
)
urwid
.
connect_signal
(
self
.
commandline
,
'execute_command'
,
self
.
_execute_input
)
urwid
.
connect_signal
(
self
.
console
,
'close'
,
self
.
_hide_console
)
self
.
mainwindow
=
urwid
.
Pile
([
(
'weight'
,
1
,
self
.
columns
),
...
...
@@ -62,8 +66,8 @@ class UIApplication(CLIApplicationBase):
command
=
subcommand
(
args
,
self
.
todolist
,
lambda
_
:
None
,
# TODO output
lambda
_
:
None
,
# TODO error
self
.
_output
,
self
.
_output
,
lambda
_
:
None
,
# TODO input
)
...
...
@@ -117,6 +121,27 @@ class UIApplication(CLIApplicationBase):
self
.
columns
.
contents
.
append
(
item
)
self
.
columns
.
focus_position
=
len
(
self
.
columns
.
contents
)
-
1
def
_show_console
(
self
):
self
.
mainwindow
.
contents
.
append
((
self
.
console
,
(
'pack'
,
None
)))
self
.
mainwindow
.
focus_position
=
2
def
_hide_console
(
self
):
if
self
.
_console_is_visible
():
self
.
console
.
clear
()
del
self
.
mainwindow
.
contents
[
2
]
def
_console_is_visible
(
self
):
return
len
(
self
.
mainwindow
.
contents
)
==
3
def
_print_to_console
(
self
,
p_text
):
if
not
self
.
_console_is_visible
():
self
.
_show_console
()
self
.
console
.
print_text
(
p_text
)
def
_output
(
self
,
p_text
):
self
.
_print_to_console
(
p_text
+
"
\
n
"
)
def
run
(
self
):
self
.
todofile
=
TodoFile
.
TodoFile
(
config
().
todotxt
())
self
.
todolist
=
TodoList
.
TodoList
(
self
.
todofile
.
read
())
...
...
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