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