Code refactor and make config assertions more verbose on fail
This commit is contained in:
parent
eb6f3cf9db
commit
6bd24cdd3e
14
gui.py
14
gui.py
|
@ -9,6 +9,7 @@ import api
|
||||||
#globals:
|
#globals:
|
||||||
COLOR_BLUE = "rgb(33, 150, 243)"
|
COLOR_BLUE = "rgb(33, 150, 243)"
|
||||||
COLOR_BLUE_SHADOW = "rgba(33, 150, 243, 0.75)"
|
COLOR_BLUE_SHADOW = "rgba(33, 150, 243, 0.75)"
|
||||||
|
WIDTH = 512
|
||||||
|
|
||||||
class MyApp(App):
|
class MyApp(App):
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
|
@ -16,12 +17,11 @@ class MyApp(App):
|
||||||
super(MyApp, self).__init__(*args, static_file_path=res_path)
|
super(MyApp, self).__init__(*args, static_file_path=res_path)
|
||||||
|
|
||||||
def main(self):
|
def main(self):
|
||||||
container = gui.VBox(width=512)
|
container = gui.VBox(width=WIDTH)
|
||||||
container.style["margin-left"] = "auto"
|
container.style.update({"margin-left": "auto", "margin-right":"auto"})
|
||||||
container.style["margin-right"] = "auto"
|
|
||||||
|
|
||||||
#logo:
|
#logo:
|
||||||
container.append(gui.Image('/res/logo.jpg', width=512))
|
container.append(gui.Image('/res/logo.png', width=WIDTH))
|
||||||
|
|
||||||
#playback controls
|
#playback controls
|
||||||
self.playback = Namespace()
|
self.playback = Namespace()
|
||||||
|
@ -38,8 +38,8 @@ class MyApp(App):
|
||||||
self.playback.volume_label = gui.Label("Volume:")
|
self.playback.volume_label = gui.Label("Volume:")
|
||||||
self.playback.volume_label.style["font-size"] = "0.8em"
|
self.playback.volume_label.style["font-size"] = "0.8em"
|
||||||
self.playback.volume_slider = gui.Slider(100, 0, 100, 1, width="150px")
|
self.playback.volume_slider = gui.Slider(100, 0, 100, 1, width="150px")
|
||||||
self.playback.volume_slider.style["margin-left"] = "20px"
|
self.playback.volume_slider \
|
||||||
self.playback.volume_slider.style["margin-bottom"] = "13px"
|
.style.update({"margin-left": "20px", "margin-bottom":"13px"})
|
||||||
self.playback.volume_slider.set_oninput_listener(self.change_volume)
|
self.playback.volume_slider.set_oninput_listener(self.change_volume)
|
||||||
|
|
||||||
self.playback.seek_slider = gui.Slider(0, 0, 100, 1, width="85%", height=20, margin='10px')
|
self.playback.seek_slider = gui.Slider(0, 0, 100, 1, width="85%", height=20, margin='10px')
|
||||||
|
@ -67,7 +67,7 @@ class MyApp(App):
|
||||||
|
|
||||||
#input
|
#input
|
||||||
container.append(gui.Label("Add songs:"))
|
container.append(gui.Label("Add songs:"))
|
||||||
inputContainer = gui.HBox(width=512)
|
inputContainer = gui.HBox(width=WIDTH)
|
||||||
self.input = Namespace()
|
self.input = Namespace()
|
||||||
self.input.field = gui.TextInput(single_line=True, height="20px", margin="5px")
|
self.input.field = gui.TextInput(single_line=True, height="20px", margin="5px")
|
||||||
self.input.field.style["border"] = "1px solid %s" % COLOR_BLUE
|
self.input.field.style["border"] = "1px solid %s" % COLOR_BLUE
|
||||||
|
|
8
main.py
8
main.py
|
@ -10,10 +10,10 @@ import gui
|
||||||
# config.start_browser: bool
|
# config.start_browser: bool
|
||||||
# config.multiple_instance: bool
|
# config.multiple_instance: bool
|
||||||
def main(config):
|
def main(config):
|
||||||
assert hasattr(config, "host")
|
assert hasattr(config, "host"), "Config has no attr 'host'!"
|
||||||
assert hasattr(config, "port")
|
assert hasattr(config, "port"), "Config has no attr 'port'!"
|
||||||
assert hasattr(config, "start_browser")
|
assert hasattr(config, "start_browser"), "Config has no attr 'start_browser'!"
|
||||||
assert hasattr(config, "multiple_instance")
|
assert hasattr(config, "multiple_instance"), "Config has no attr 'multiple_instance'!"
|
||||||
|
|
||||||
# start the webserver:
|
# start the webserver:
|
||||||
api.BASE_URL = config.api_base
|
api.BASE_URL = config.api_base
|
||||||
|
|
Loading…
Reference in New Issue