Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
papersurfer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jacobsohn, Johann
papersurfer
Commits
52d1038d
Commit
52d1038d
authored
4 years ago
by
Johann Jacobsohn
Browse files
Options
Downloads
Patches
Plain Diff
make buttons prettier
parent
f6974d1b
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
papersurfer/papersurfer.py
+48
-26
48 additions, 26 deletions
papersurfer/papersurfer.py
with
48 additions
and
26 deletions
papersurfer/papersurfer.py
+
48
−
26
View file @
52d1038d
...
...
@@ -15,6 +15,7 @@ import re
from
functools
import
partial
import
json
import
time
import
os
import
requests
import
mattermostdriver
import
urwid
...
...
@@ -194,23 +195,40 @@ class Mattermost:
or
needle
.
lower
()
in
m
.
reporter
.
lower
()]
class
PrettyButton
(
urwid
.
Button
):
button_left
=
urwid
.
Text
(
'
[
'
)
button_right
=
urwid
.
Text
(
'
]
'
)
class
PrettyButton
(
urwid
.
WidgetWrap
):
def
__init__
(
self
,
label
,
on_press
=
None
,
user_data
=
None
):
self
.
text
=
urwid
.
Text
(
""
)
self
.
set_label
(
label
)
self
.
widget
=
urwid
.
AttrMap
(
self
.
text
,
''
,
'
highlight
'
)
# use a hidden button for evt handling
self
.
_hidden_btn
=
urwid
.
Button
(
f
"
hidden
{
self
.
label
}
"
,
on_press
,
user_data
)
super
(
self
.
__class__
,
self
).
__init__
(
self
.
widget
)
def
selectable
(
self
):
return
True
def
keypress
(
self
,
*
args
,
**
kw
):
return
self
.
_hidden_btn
.
keypress
(
*
args
,
**
kw
)
def
__init__
(
self
,
*
args
,
onclick
=
lambda
*
x
:
x
,
**
kwargs
):
super
(
self
.
__class__
,
self
).
__init__
(
*
args
,
**
kwargs
)
urwid
.
connect_signal
(
self
,
'
click
'
,
onclick
)
def
mouse_event
(
self
,
*
args
,
**
kw
):
return
self
.
_hidden_btn
.
mouse_event
(
*
args
,
**
kw
)
def
get_label
(
self
):
return
self
.
label
def
set_label
(
self
,
label
):
self
.
label
=
label
self
.
text
.
set_text
(
f
"
[
{
label
}
]
"
)
class
Papersurfer
:
"""
Provide UI and interface with mattermost class.
"""
def
__init__
(
self
,
url
,
channel
,
username
,
password
):
self
.
_screen
=
urwid
.
raw_display
.
Screen
()
self
.
size
=
self
.
_screen
.
get_cols_rows
()
self
.
filter
=
""
palette
=
[
_palette
=
[
(
'
button
'
,
'
default,bold
'
,
'
default
'
),
(
'
I say
'
,
'
default,bold
'
,
'
default
'
,
'
bold
'
),
(
'
needle
'
,
'
default, bold, underline
'
,
'
default
'
,
'
bold
'
),
(
'
highlight
'
,
'
black
'
,
'
dark blue
'
),
...
...
@@ -219,10 +237,16 @@ class Papersurfer:
(
'
focus
'
,
'
black
'
,
'
light gray
'
),
(
'
papertitle
'
,
'
default,bold
'
,
'
default
'
,
'
bold
'
)
]
def
__init__
(
self
,
url
,
channel
,
username
,
password
):
self
.
_screen
=
urwid
.
raw_display
.
Screen
()
self
.
size
=
self
.
_screen
.
get_cols_rows
()
self
.
filter
=
""
ask
=
urwid
.
Edit
((
'
I say
'
,
u
"
Filter?
\n
"
))
exitbutton
=
PrettyButton
(
u
'
Exit
'
,
on
click
=
self
.
on_exit_clicked
)
exitbutton
=
PrettyButton
(
u
'
Exit
'
,
on
_press
=
self
.
on_exit_clicked
)
self
.
exportbutton
=
PrettyButton
(
u
'
Export filtered list as bibtex
'
,
on
click
=
self
.
on_export_clicked
)
on
_press
=
self
.
on_export_clicked
)
div
=
urwid
.
Divider
(
u
'
-
'
)
self
.
mtm
=
Mattermost
(
url
,
channel
,
username
,
password
)
...
...
@@ -251,7 +275,7 @@ class Papersurfer:
urwid
.
connect_signal
(
ask
,
'
change
'
,
self
.
onchange
)
self
.
main
=
pile
self
.
mainloop
=
urwid
.
MainLoop
(
self
.
_over
,
palette
)
self
.
mainloop
=
urwid
.
MainLoop
(
self
.
_over
,
self
.
_
palette
)
self
.
mainloop
.
set_alarm_in
(.
1
,
self
.
load_list
)
self
.
mainloop
.
run
()
...
...
@@ -294,8 +318,7 @@ class Papersurfer:
body
=
urwid
.
LineBox
(
body_padding
)
# Footer
footer
=
urwid
.
Button
(
'
Okay
'
,
self
.
close_details
)
footer
=
urwid
.
AttrWrap
(
footer
,
'
selectable
'
,
'
focus
'
)
footer
=
PrettyButton
(
'
Okay
'
,
self
.
close_details
)
footer
=
urwid
.
GridFlow
([
footer
],
8
,
1
,
1
,
'
center
'
)
# Layout
...
...
@@ -322,12 +345,12 @@ class Papersurfer:
title
=
urwid
.
Text
(
text_items
)
discuss_button
=
PrettyButton
(
"
Open Discussion
"
,
on
click
=
partial
(
self
.
h_open_discussion
,
on
_press
=
partial
(
self
.
h_open_discussion
,
paper
))
doi_button
=
PrettyButton
(
"
Open DOI
"
,
on
click
=
partial
(
self
.
h_open_doi
,
paper
))
on
_press
=
partial
(
self
.
h_open_doi
,
paper
))
details_button
=
PrettyButton
(
"
Show details
"
,
on
click
=
partial
(
self
.
h_show_details
,
on
_press
=
partial
(
self
.
h_show_details
,
paper
))
button_bar
=
urwid
.
Columns
([
...
...
@@ -419,7 +442,6 @@ def get_config_file_paths():
<
class
'
list
'
>
"""
import os
env = os.environ
xdg_home = None
if
'
XDG_CONFIG_HOME
'
in env:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment