mirror of
https://github.com/Febbweiss/mopidy-touchscreen.git
synced 2026-03-04 22:25:39 +00:00
Fix flake8
This commit is contained in:
@@ -3,7 +3,7 @@ import pygame
|
|||||||
change_speed = 2
|
change_speed = 2
|
||||||
|
|
||||||
|
|
||||||
class DynamicBackground():
|
class DynamicBackground:
|
||||||
|
|
||||||
def __init__(self, size):
|
def __init__(self, size):
|
||||||
self.image_loaded = False
|
self.image_loaded = False
|
||||||
@@ -41,14 +41,14 @@ class DynamicBackground():
|
|||||||
self.update = True
|
self.update = True
|
||||||
|
|
||||||
|
|
||||||
def get_aspect_scale_size(img, (bx, by)):
|
@staticmethod
|
||||||
|
def get_aspect_scale_size(img, size):
|
||||||
size = img.get_size()
|
size = img.get_size()
|
||||||
aspect_x = bx / float(size[0])
|
aspect_x = size[0] / float(size[0])
|
||||||
aspect_y = by / float(size[1])
|
aspect_y = size[1] / float(size[1])
|
||||||
if aspect_x > aspect_y:
|
if aspect_x > aspect_y:
|
||||||
aspect = aspect_x
|
aspect = aspect_x
|
||||||
else:
|
else:
|
||||||
aspect = aspect_y
|
aspect = aspect_y
|
||||||
|
|
||||||
new_size = (int(aspect*size[0]), int(aspect*size[1]))
|
new_size = (int(aspect*size[0]), int(aspect*size[1]))
|
||||||
return new_size
|
return new_size
|
||||||
|
|||||||
@@ -78,35 +78,35 @@ class ScreenManager():
|
|||||||
|
|
||||||
# Search button
|
# Search button
|
||||||
button = TouchAndTextItem(self.fonts['icon'], u" \ue986",
|
button = TouchAndTextItem(self.fonts['icon'], u" \ue986",
|
||||||
(0, self.size[1] - self.base_size), #change these to move the location of the icons
|
(0, self.size[1] - self.base_size),
|
||||||
button_size, center=True)
|
button_size, center=True)
|
||||||
self.down_bar_objects.set_touch_object("menu_0", button)
|
self.down_bar_objects.set_touch_object("menu_0", button)
|
||||||
x = button.get_right_pos()
|
x = button.get_right_pos()
|
||||||
|
|
||||||
# Main button
|
# Main button
|
||||||
button = TouchAndTextItem(self.fonts['icon'], u" \ue600",
|
button = TouchAndTextItem(self.fonts['icon'], u" \ue600",
|
||||||
(x, self.size[1] - self.base_size), #change these to move the location of the icons
|
(x, self.size[1] - self.base_size),
|
||||||
button_size, center=True)
|
button_size, center=True)
|
||||||
self.down_bar_objects.set_touch_object("menu_1", button)
|
self.down_bar_objects.set_touch_object("menu_1", button)
|
||||||
x = button.get_right_pos()
|
x = button.get_right_pos()
|
||||||
|
|
||||||
# Tracklist button
|
# Tracklist button
|
||||||
button = TouchAndTextItem(self.fonts['icon'], u" \ue60d",
|
button = TouchAndTextItem(self.fonts['icon'], u" \ue60d",
|
||||||
(x, self.size[1] - self.base_size), #change these to move the location of the icons
|
(x, self.size[1] - self.base_size),
|
||||||
button_size, center=True)
|
button_size, center=True)
|
||||||
self.down_bar_objects.set_touch_object("menu_2", button)
|
self.down_bar_objects.set_touch_object("menu_2", button)
|
||||||
x = button.get_right_pos()
|
x = button.get_right_pos()
|
||||||
|
|
||||||
# Library button
|
# Library button
|
||||||
button = TouchAndTextItem(self.fonts['icon'], u" \ue604",
|
button = TouchAndTextItem(self.fonts['icon'], u" \ue604",
|
||||||
(x, self.size[1] - self.base_size), #change these to move the location of the icons
|
(x, self.size[1] - self.base_size),
|
||||||
button_size, center=True)
|
button_size, center=True)
|
||||||
self.down_bar_objects.set_touch_object("menu_3", button)
|
self.down_bar_objects.set_touch_object("menu_3", button)
|
||||||
x = button.get_right_pos()
|
x = button.get_right_pos()
|
||||||
|
|
||||||
# Playlist button
|
# Playlist button
|
||||||
button = TouchAndTextItem(self.fonts['icon'], u" \ue605",
|
button = TouchAndTextItem(self.fonts['icon'], u" \ue605",
|
||||||
(x, self.size[1] - self.base_size), #change these to move the location of the icons
|
(x, self.size[1] - self.base_size),
|
||||||
button_size, center=True)
|
button_size, center=True)
|
||||||
|
|
||||||
self.down_bar_objects.set_touch_object("menu_4", button)
|
self.down_bar_objects.set_touch_object("menu_4", button)
|
||||||
@@ -114,18 +114,18 @@ class ScreenManager():
|
|||||||
|
|
||||||
# Menu button
|
# Menu button
|
||||||
button = TouchAndTextItem(self.fonts['icon'], u" \ue60a",
|
button = TouchAndTextItem(self.fonts['icon'], u" \ue60a",
|
||||||
(x, self.size[1] - self.base_size), #change these to move the location of the icons
|
(x, self.size[1] - self.base_size),
|
||||||
button_size,
|
button_size,
|
||||||
center=True)
|
center=True)
|
||||||
self.down_bar_objects.set_touch_object("menu_5", button)
|
self.down_bar_objects.set_touch_object("menu_5", button)
|
||||||
|
|
||||||
# Down bar Solid
|
# Down bar Solid
|
||||||
self.down_bar_solid = pygame.Surface(
|
self.down_bar_solid = pygame.Surface(
|
||||||
(self.size[0], self.size[1] - self.base_size )) #change the 7 to move the bar
|
(self.size[0], self.size[1] - self.base_size))
|
||||||
|
|
||||||
# Down bar
|
# Down bar
|
||||||
self.down_bar = pygame.Surface(
|
self.down_bar = pygame.Surface(
|
||||||
(self.size[0], self.size[1] - self.base_size ), #change the 7 to move the bar
|
(self.size[0], self.size[1] - self.base_size),
|
||||||
pygame.SRCALPHA)
|
pygame.SRCALPHA)
|
||||||
self.down_bar.fill((0, 0, 0, 200))
|
self.down_bar.fill((0, 0, 0, 200))
|
||||||
|
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ class Keyboard(BaseScreen):
|
|||||||
self.listener.text_input(text)
|
self.listener.text_input(text)
|
||||||
self.manager.close_keyboard()
|
self.manager.close_keyboard()
|
||||||
elif touch_event.type == InputManager.key:
|
elif touch_event.type == InputManager.key:
|
||||||
if isinstance(touch_event.unicode, unicode):
|
if not isinstance(touch_event.unicode, int):
|
||||||
if touch_event.unicode == u'\x08':
|
if touch_event.unicode == u'\x08':
|
||||||
self.other_objects.get_object("text").remove_text(1, False)
|
self.other_objects.get_object("text").remove_text(1, False)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -107,9 +107,9 @@ class MainScreen(BaseScreen):
|
|||||||
screen.blit(self.top_bar, (0, 0))
|
screen.blit(self.top_bar, (0, 0))
|
||||||
self.touch_text_manager.render(screen)
|
self.touch_text_manager.render(screen)
|
||||||
if self.image is not None:
|
if self.image is not None:
|
||||||
screen.blit(self.image, (
|
screen.blit(self.image, (
|
||||||
self.base_size / 2, self.base_size +
|
self.base_size / 2, self.base_size +
|
||||||
self.base_size / 2))
|
self.base_size / 2))
|
||||||
|
|
||||||
elif update_type == BaseScreen.update_partial \
|
elif update_type == BaseScreen.update_partial \
|
||||||
and self.track is not None:
|
and self.track is not None:
|
||||||
@@ -150,26 +150,26 @@ class MainScreen(BaseScreen):
|
|||||||
|
|
||||||
# Track name
|
# Track name
|
||||||
label = TextItem(self.fonts['base'],
|
label = TextItem(self.fonts['base'],
|
||||||
MainScreen.get_track_name(track),
|
MainScreen.get_track_name(track),
|
||||||
(x, self.base_size * 2), (width, -1))
|
(x, self.base_size * 2), (width, -1))
|
||||||
if not label.fit_horizontal:
|
if not label.fit_horizontal:
|
||||||
self.update_keys.append("track_name")
|
self.update_keys.append("track_name")
|
||||||
self.touch_text_manager.set_object("track_name", label)
|
self.touch_text_manager.set_object("track_name", label)
|
||||||
|
|
||||||
# Album name
|
# Album name
|
||||||
label = TextItem(self.fonts['base'],
|
label = TextItem(self.fonts['base'],
|
||||||
MainScreen.get_track_album_name
|
MainScreen.get_track_album_name
|
||||||
(track), (x, self.base_size * 3),
|
(track), (x, self.base_size * 3),
|
||||||
(width, -1))
|
(width, -1))
|
||||||
if not label.fit_horizontal:
|
if not label.fit_horizontal:
|
||||||
self.update_keys.append("album_name")
|
self.update_keys.append("album_name")
|
||||||
self.touch_text_manager.set_object("album_name", label)
|
self.touch_text_manager.set_object("album_name", label)
|
||||||
|
|
||||||
# Artist
|
# Artist
|
||||||
label = TextItem(self.fonts['base'],
|
label = TextItem(self.fonts['base'],
|
||||||
self.get_artist_string(),
|
self.get_artist_string(),
|
||||||
(x, self.base_size * 4),
|
(x, self.base_size * 4),
|
||||||
(width, -1))
|
(width, -1))
|
||||||
if not label.fit_horizontal:
|
if not label.fit_horizontal:
|
||||||
self.update_keys.append("artist_name")
|
self.update_keys.append("artist_name")
|
||||||
self.touch_text_manager.set_object("artist_name", label)
|
self.touch_text_manager.set_object("artist_name", label)
|
||||||
@@ -276,36 +276,33 @@ class MainScreen(BaseScreen):
|
|||||||
width = self.size[0] - self.base_size
|
width = self.size[0] - self.base_size
|
||||||
|
|
||||||
current = TextItem(self.fonts['base'],
|
current = TextItem(self.fonts['base'],
|
||||||
MainScreen.get_track_name
|
MainScreen.get_track_name
|
||||||
(self.track),
|
(self.track),
|
||||||
(self.base_size / 2,
|
(self.base_size / 2,
|
||||||
self.base_size * 2),
|
self.base_size * 2),
|
||||||
(width, -1))
|
(width, -1))
|
||||||
if not current.fit_horizontal:
|
if not current.fit_horizontal:
|
||||||
self.update_keys.append("track_name")
|
self.update_keys.append("track_name")
|
||||||
self.touch_text_manager.set_object("track_name",
|
self.touch_text_manager.set_object("track_name", current)
|
||||||
current)
|
|
||||||
|
|
||||||
current = TextItem(self.fonts['base'],
|
current = TextItem(self.fonts['base'],
|
||||||
MainScreen.get_track_album_name
|
MainScreen.get_track_album_name
|
||||||
(self.track),
|
(self.track),
|
||||||
(self.base_size / 2,
|
(self.base_size / 2,
|
||||||
self.base_size * 3),
|
self.base_size * 3),
|
||||||
(width, -1))
|
(width, -1))
|
||||||
if not current.fit_horizontal:
|
if not current.fit_horizontal:
|
||||||
self.update_keys.append("album_name")
|
self.update_keys.append("album_name")
|
||||||
self.touch_text_manager.set_object("album_name",
|
self.touch_text_manager.set_object("album_name", current)
|
||||||
current)
|
|
||||||
|
|
||||||
current = TextItem(self.fonts['base'],
|
current = TextItem(self.fonts['base'],
|
||||||
self.get_artist_string(),
|
self.get_artist_string(),
|
||||||
(self.base_size / 2,
|
(self.base_size / 2,
|
||||||
self.base_size * 4),
|
self.base_size * 4),
|
||||||
(width, -1))
|
(width, -1))
|
||||||
if not current.fit_horizontal:
|
if not current.fit_horizontal:
|
||||||
self.update_keys.append("artist_name")
|
self.update_keys.append("artist_name")
|
||||||
self.touch_text_manager.set_object("artist_name",
|
self.touch_text_manager.set_object("artist_name", current)
|
||||||
current)
|
|
||||||
|
|
||||||
self.background.set_background_image(None)
|
self.background.set_background_image(None)
|
||||||
|
|
||||||
@@ -317,25 +314,22 @@ class MainScreen(BaseScreen):
|
|||||||
width = self.size[0] - self.base_size
|
width = self.size[0] - self.base_size
|
||||||
|
|
||||||
current = TextItem(self.fonts['base'], "",
|
current = TextItem(self.fonts['base'], "",
|
||||||
(self.base_size / 2,
|
(self.base_size / 2,
|
||||||
self.base_size * 2),
|
self.base_size * 2),
|
||||||
(width, -1))
|
(width, -1))
|
||||||
self.touch_text_manager.set_object("track_name",
|
self.touch_text_manager.set_object("track_name", current)
|
||||||
current)
|
|
||||||
|
|
||||||
current = TextItem(self.fonts['base'], "",
|
current = TextItem(self.fonts['base'], "",
|
||||||
(self.base_size / 2,
|
(self.base_size / 2,
|
||||||
self.base_size * 3),
|
self.base_size * 3),
|
||||||
(width, -1))
|
(width, -1))
|
||||||
self.touch_text_manager.set_object("album_name",
|
self.touch_text_manager.set_object("album_name", current)
|
||||||
current)
|
|
||||||
|
|
||||||
current = TextItem(self.fonts['base'], "",
|
current = TextItem(self.fonts['base'], "",
|
||||||
(self.base_size / 2,
|
(self.base_size / 2,
|
||||||
self.base_size * 4),
|
self.base_size * 4),
|
||||||
(width, -1))
|
(width, -1))
|
||||||
self.touch_text_manager.set_object("artist_name",
|
self.touch_text_manager.set_object("artist_name", current)
|
||||||
current)
|
|
||||||
|
|
||||||
def load_image(self):
|
def load_image(self):
|
||||||
size = self.base_size * 4
|
size = self.base_size * 4
|
||||||
@@ -484,7 +478,7 @@ class MainScreen(BaseScreen):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_track_album_name(track):
|
def get_track_album_name(track):
|
||||||
if track.album is not None and track.album.name is not None\
|
if track.album is not None and track.album.name is not None \
|
||||||
and len(track.album.name) > 0:
|
and len(track.album.name) > 0:
|
||||||
return track.album.name
|
return track.album.name
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user