black -t py34
This commit is contained in:
parent
e1a9782458
commit
7215a11ffe
1 changed files with 14 additions and 7 deletions
|
@ -5,6 +5,7 @@ import core.module
|
||||||
import core.widget
|
import core.widget
|
||||||
import core.input
|
import core.input
|
||||||
import core.decorators
|
import core.decorators
|
||||||
|
|
||||||
"""Displays the current song being played and allows pausing, skipping ahead, and skipping back.
|
"""Displays the current song being played and allows pausing, skipping ahead, and skipping back.
|
||||||
|
|
||||||
Requires the following library:
|
Requires the following library:
|
||||||
|
@ -17,11 +18,15 @@ Parameters:
|
||||||
Widget names are: spotify-buttons.song, spotify-buttons.prev, spotify-buttons.pause, spotify-buttons.next
|
Widget names are: spotify-buttons.song, spotify-buttons.prev, spotify-buttons.pause, spotify-buttons.next
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class Module(core.module.Module):
|
class Module(core.module.Module):
|
||||||
def __init__(self, config, theme):
|
def __init__(self, config, theme):
|
||||||
super().__init__(config, theme, [])
|
super().__init__(config, theme, [])
|
||||||
|
|
||||||
self.__layout = self.parameter("layout", "spotify-buttons.song spotify-buttons.prev spotify-buttons.pause spotify-buttons.next")
|
self.__layout = self.parameter(
|
||||||
|
"layout",
|
||||||
|
"spotify-buttons.song spotify-buttons.prev spotify-buttons.pause spotify-buttons.next",
|
||||||
|
)
|
||||||
|
|
||||||
self.__song = ""
|
self.__song = ""
|
||||||
self.__pause = ""
|
self.__pause = ""
|
||||||
|
@ -55,10 +60,10 @@ class Module(core.module.Module):
|
||||||
artist=",".join(props.get("xesam:artist")),
|
artist=",".join(props.get("xesam:artist")),
|
||||||
trackNumber=str(props.get("xesam:trackNumber")),
|
trackNumber=str(props.get("xesam:trackNumber")),
|
||||||
)
|
)
|
||||||
#this feels like a stupid way to do this but its all i can think of
|
# this feels like a stupid way to do this but its all i can think of
|
||||||
widget_map = {}
|
widget_map = {}
|
||||||
for widget_name in self.__layout.split():
|
for widget_name in self.__layout.split():
|
||||||
widget = self.add_widget(name = widget_name)
|
widget = self.add_widget(name=widget_name)
|
||||||
if widget_name == "spotify-buttons.prev":
|
if widget_name == "spotify-buttons.prev":
|
||||||
widget_map[widget] = {
|
widget_map[widget] = {
|
||||||
"button": core.input.LEFT_MOUSE,
|
"button": core.input.LEFT_MOUSE,
|
||||||
|
@ -81,7 +86,9 @@ class Module(core.module.Module):
|
||||||
widget.full_text(self.__song)
|
widget.full_text(self.__song)
|
||||||
else:
|
else:
|
||||||
raise KeyError(
|
raise KeyError(
|
||||||
"The spotify-buttons module does not have a {widget_name!r} widget".format(widget_name=widget_name)
|
"The spotify-buttons module does not have a {widget_name!r} widget".format(
|
||||||
|
widget_name=widget_name
|
||||||
|
)
|
||||||
)
|
)
|
||||||
for widget, callback_options in widget_map.items():
|
for widget, callback_options in widget_map.items():
|
||||||
core.input.register(widget, **callback_options)
|
core.input.register(widget, **callback_options)
|
||||||
|
|
Loading…
Reference in a new issue