Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Fjen Undso
nchl
Commits
97dda306
Commit
97dda306
authored
Aug 30, 2019
by
Fjen Undso
Browse files
cleanup
parent
8d5f58d4
Changes
6
Hide whitespace changes
Inline
Side-by-side
gui/checkbox.py
View file @
97dda306
...
...
@@ -32,12 +32,10 @@ class CheckBox(Drawable):
def
_get_text
(
self
):
prefix
=
"[X] "
if
self
.
active
else
"[ ] "
return
"{
}{}"
.
format
(
prefix
,
self
.
text
)
return
f
"
{
prefix
}{
self
.
text
}
"
def
draw
(
self
):
attr
=
curses
.
A_NORMAL
if
self
.
focus
:
attr
=
curses
.
A_STANDOUT
attr
=
curses
.
A_STANDOUT
if
self
.
focus
else
curses
.
A_NORMAL
self
.
window
.
move
(
self
.
row
,
self
.
col
)
self
.
window
.
addstr
(
self
.
_get_text
(),
attr
)
self
.
window
.
refresh
()
...
...
@@ -45,10 +43,8 @@ class CheckBox(Drawable):
def
send_key
(
self
,
key
):
if
key
==
self
.
toggle_key_unfocused
:
self
.
toggle
()
if
not
self
.
focus
:
return
if
key
==
self
.
toggle_key
:
self
.
toggle
()
...
...
gui/container/focusswitcher.py
View file @
97dda306
...
...
@@ -43,7 +43,6 @@ class FocusSwitcher(Focusable):
"""Switch focus if known key or forward it to all our elements."""
if
not
self
.
focus
:
return
if
key
==
self
.
prev_key
:
self
.
prev
()
elif
key
==
self
.
next_key
:
...
...
gui/curseshandler.py
View file @
97dda306
...
...
@@ -21,8 +21,7 @@ class CursesHandler(logging.Handler):
try
:
msg
=
self
.
format
(
record
)
screen
=
self
.
screen
fs
=
"
\n
%s"
screen
.
addstr
(
fs
%
msg
)
screen
.
addstr
(
"
\n
%s"
%
msg
)
screen
.
refresh
()
except
(
KeyboardInterrupt
,
SystemExit
):
raise
...
...
gui/numberrange.py
View file @
97dda306
...
...
@@ -39,20 +39,16 @@ class NumberRange(Drawable):
Drawable
.
__init__
(
self
,
window
=
window
,
row
=
row
,
col
=
col
)
def
draw
(
self
):
attr
=
curses
.
A_NORMAL
if
self
.
focus
:
attr
=
self
.
attr
attr
=
self
.
attr
if
self
.
focus
else
curses
.
A_NORMAL
self
.
window
.
move
(
self
.
row
,
self
.
col
)
self
.
window
.
addstr
(
self
.
text
+
"<"
)
formatter
=
"{:>"
+
str
(
len
(
str
(
self
.
max
)))
+
"}"
self
.
window
.
addstr
(
formatter
.
format
(
self
.
value
),
attr
)
self
.
window
.
addstr
(
f
"
{
self
.
text
}
<"
)
self
.
window
.
addstr
(
f
"
{
self
.
value
:
>
{
len
(
str
(
self
.
max
))
}}
"
,
attr
)
self
.
window
.
addstr
(
">"
)
self
.
window
.
refresh
()
def
send_key
(
self
,
key
):
if
not
self
.
focus
:
return
if
key
==
self
.
prev_key
:
self
.
decr
()
elif
key
==
self
.
next_key
:
...
...
@@ -63,7 +59,7 @@ class NumberRange(Drawable):
self
.
set
(
int
(
key
))
else
:
# add number on right side
self
.
set
(
int
(
str
(
self
.
value
)
+
key
))
self
.
set
(
int
(
f
"
{
self
.
value
}{
key
}
"
))
def
send_mouse
(
self
,
mx
,
my
):
pass
...
...
@@ -74,8 +70,7 @@ class NumberRange(Drawable):
Args:
value: the value to set.
"""
self
.
value
=
min
(
value
,
self
.
max
)
self
.
value
=
max
(
self
.
value
,
self
.
min
)
self
.
value
=
max
(
min
(
value
,
self
.
max
),
self
.
min
)
self
.
draw
()
def
incr
(
self
):
...
...
gui/progressbar.py
View file @
97dda306
...
...
@@ -10,9 +10,10 @@ class ProgressBar(Drawable):
height: The height including frame.
value: Initial value.
max_value: Maximum value.
t
ext
: Text to show on top of the progressbar.
t
itle
: Text to show on top of the progressbar.
attr: Curses attribute of the progress indicator.
"""
characters
=
"▁▂▃▄▅▆▇█"
def
__init__
(
self
,
...
...
@@ -24,23 +25,23 @@ class ProgressBar(Drawable):
height
=
0
,
value
=
0
,
max_value
=
100
,
t
ext
=
""
,
t
itle
=
""
,
attr
=
curses
.
A_STANDOUT
):
assert
width
>
2
assert
height
>
2
self
.
characters
=
"▁▂▃▄▅▆▇█"
self
.
value
=
value
self
.
max
=
max_value
self
.
t
ext
=
text
self
.
t
itle
=
title
self
.
attr
=
attr
# draw frame
self
.
window
=
window
.
subwin
(
height
,
width
,
row
,
col
)
self
.
window
.
border
(
0
)
if
len
(
self
.
text
)
>
width
:
self
.
window
.
addstr
(
self
.
text
)
# add title if possible
if
len
(
self
.
title
)
>
width
:
self
.
window
.
addstr
(
self
.
title
)
else
:
self
.
window
.
addstr
(
0
,
(
width
-
len
(
self
.
t
ext
))
//
2
,
self
.
t
ext
)
self
.
window
.
addstr
(
0
,
(
width
-
len
(
self
.
t
itle
))
//
2
,
self
.
t
itle
)
# inner box
self
.
width
=
width
-
2
self
.
height
=
height
-
2
...
...
@@ -74,8 +75,7 @@ class ProgressBar(Drawable):
Args:
value: the value to set.
"""
self
.
value
=
min
(
value
,
self
.
max
)
self
.
value
=
max
(
self
.
value
,
0
)
self
.
value
=
max
(
min
(
value
,
self
.
max
),
0
)
self
.
draw
()
def
send_key
(
self
,
key
):
...
...
nchl.py
View file @
97dda306
...
...
@@ -80,7 +80,7 @@ class NCHL:
value
=
255
,
max_value
=
255
,
attr
=
curses
.
color_pair
(
numbers_text
[
i
][
1
]),
t
ext
=
numbers_text
[
i
][
0
],
t
itle
=
numbers_text
[
i
][
0
],
)
for
i
in
range
(
len
(
numbers_text
))
]
...
...
Write
Preview
Supports
Markdown
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