def __init__(self, parent): super(Interpreters, self).__init__(parent) self.container = ScrollableFrame(parent, style="DarkGray.TFrame") self.interpretersItems = [] self.interpretersList = Frame(self.container.interior, style="DarkGray.TFrame") self.interpretersList.pack(fill='x') ListItem(self.interpretersList, ['Número', 'Nome', 'Tipo'], None, True)
class Composers(Component): def __init__(self, parent): super(Composers, self).__init__(parent) self.container = ScrollableFrame(parent, style="DarkGray.TFrame") self.composerItems = [] self.composerList = Frame(self.container.interior, style="DarkGray.TFrame") self.composerList.pack(fill='x') ListItem(self.composerList, [ 'Número', 'Período Musical', 'Nome', 'Cidade', 'País', 'Data de Nascimento', 'Data de Morte' ], None, True) def loadContent(self): DBController.execute(''' SELECT c.cod, pm.descricao, c.nome, c.cidade, c.pais, c.dt_nasc, c.dt_morte FROM Compositor c INNER JOIN Periodo_Musical pm ON c.pr_msc=pm.cod ''') self.composerData = list(DBController.get()) def pack(self): for composer in self.composerItems: composer.unpack() self.composerItems = [] self.loadContent() for composer in self.composerData: def _(composer): dt1 = composer[5] dt2 = composer[6] last_t = "%02d/%02d/%02d" % (dt2.day, dt2.month, dt2.year) if dt2 else 'VIVO' titles = [ composer[0], composer[1], composer[2], composer[3], composer[4], "%02d/%02d/%02d" % (dt1.day, dt1.month, dt1.year), last_t ] def gotocomposer(_): Navigate.goto('_cp', composer) self.composerItems.append( ListItem(self.composerList, titles, gotocomposer)) _(composer) self.container.pack(expand=True, fill='both')
def __init__(self, parent): super(Albums, self).__init__(parent) self.container = ScrollableFrame(parent, style="DarkGray.TFrame") self.albumsItems = [] self.albumsList = Frame(self.container.interior, style="DarkGray.TFrame") self.albumsList.pack(fill='x') ListItem(self.albumsList, [ 'Número', 'Gravadora', 'Preço', 'Data de Compra', 'Data de Gravação', 'Tipo de Compra', 'Descrição' ], None, True)
def __init__(self, parent, query=None): super(Playlists, self).__init__(parent) self.container = ScrollableFrame(parent, style="DarkGray.TFrame") self.query = query self.playlistsItems = [] self.playlistsList = Frame(self.container.interior, style="DarkGray.TFrame") self.playlistsList.pack(fill='x') ListItem(self.playlistsList, ['Número', 'Nome', 'Data de Criação', 'Tempo total'], None, True)
def __init__(self, parent): super(Composers, self).__init__(parent) self.container = ScrollableFrame(parent, style="DarkGray.TFrame") self.composerItems = [] self.composerList = Frame(self.container.interior, style="DarkGray.TFrame") self.composerList.pack(fill='x') ListItem(self.composerList, [ 'Número', 'Período Musical', 'Nome', 'Cidade', 'País', 'Data de Nascimento', 'Data de Morte' ], None, True)
class Playlists(Component): def __init__(self, parent, query=None): super(Playlists, self).__init__(parent) self.container = ScrollableFrame(parent, style="DarkGray.TFrame") self.query = query self.playlistsItems = [] self.playlistsList = Frame(self.container.interior, style="DarkGray.TFrame") self.playlistsList.pack(fill='x') ListItem(self.playlistsList, ['Número', 'Nome', 'Data de Criação', 'Tempo total'], None, True) def loadContent(self): query = self.query if not self.query: query = ''' select * from Playlist ''' DBController.execute(query) self.playlistsData = list(DBController.get()) def pack(self): for playlist in self.playlistsItems: playlist.unpack() self.playlistsItems = [] self.loadContent() for playlist in self.playlistsData: def _(playlist): dt = playlist[2] titles = [ playlist[0], playlist[1], "%02d/%02d/%02d" % (dt.day, dt.month, dt.year), playlist[3] ] def gotoplaylist(_): Navigate.goto('_pl', playlist) self.playlistsItems.append( ListItem(self.playlistsList, titles, gotoplaylist)) _(playlist) self.container.pack(expand=True, fill='both')
class Albums(Component): def __init__(self, parent): super(Albums, self).__init__(parent) self.container = ScrollableFrame(parent, style="DarkGray.TFrame") self.albumsItems = [] self.albumsList = Frame(self.container.interior, style="DarkGray.TFrame") self.albumsList.pack(fill='x') ListItem(self.albumsList, [ 'Número', 'Gravadora', 'Preço', 'Data de Compra', 'Data de Gravação', 'Tipo de Compra', 'Descrição' ], None, True) def loadContent(self): DBController.execute(''' SELECT a.cod, g.nome, a.pr_compra, a.data_compra, a.data_grav, a.tipo_compra, a.descricao FROM Album a INNER JOIN Gravadora g ON a.codgrav=g.cod ''') self.albumsData = list(DBController.get()) def pack(self): for album in self.albumsItems: album.unpack() self.albumsItems = [] self.loadContent() for album in self.albumsData: def _(album): dt = album[3] titles = [ album[0], album[1], album[2], "%02d/%02d/%02d" % (dt.day, dt.month, dt.year), album[4], album[5], album[6] ] def gotoalbum(_): Navigate.goto('_ab', album) self.albumsItems.append( ListItem(self.albumsList, titles, gotoalbum)) _(album) self.container.pack(expand=True, fill='both')
def __init__(self, parent, query=None, callback=None): super(Songs, self).__init__(parent) self.container = ScrollableFrame(parent, style="DarkGray.TFrame") self.callback = callback self.query = query self.songsItems = [] self.songsList = Frame(self.container.interior, style="DarkGray.TFrame") self.songsList.pack(fill='x') ListItem(self.songsList, [ 'Número', 'Playlist', 'Álbum', 'Composição', 'Tipo', 'Descrição', 'Duração' ], None, True)
class Interpreters(Component): def __init__(self, parent): super(Interpreters, self).__init__(parent) self.container = ScrollableFrame(parent, style="DarkGray.TFrame") self.interpretersItems = [] self.interpretersList = Frame(self.container.interior, style="DarkGray.TFrame") self.interpretersList.pack(fill='x') ListItem(self.interpretersList, ['Número', 'Nome', 'Tipo'], None, True) def loadContent(self): DBController.execute(''' select * from Interprete ''') self.interpretersData = list(DBController.get()) def pack(self): for interpreter in self.interpretersItems: interpreter.unpack() self.interpretersItems = [] self.loadContent() for interpreter in self.interpretersData: def _(interpreter): titles = [interpreter[0], interpreter[1], interpreter[2]] def gotointerpreter(_): Navigate.goto('_it', interpreter) self.interpretersItems.append( ListItem(self.interpretersList, titles, gotointerpreter)) _(interpreter) self.container.pack(expand=True, fill='both')
class Songs(Component): def __init__(self, parent, query=None, callback=None): super(Songs, self).__init__(parent) self.container = ScrollableFrame(parent, style="DarkGray.TFrame") self.callback = callback self.query = query self.songsItems = [] self.songsList = Frame(self.container.interior, style="DarkGray.TFrame") self.songsList.pack(fill='x') ListItem(self.songsList, [ 'Número', 'Playlist', 'Álbum', 'Composição', 'Tipo', 'Descrição', 'Duração' ], None, True) def loadContent(self): query = self.query if not self.query: query = ''' SELECT f.cod, pl.nome, a.descricao, f.tipo_comp, f.tipo_grav, f.descricao, f.tempo_exec FROM Faixa f LEFT OUTER JOIN Playlist_Faixa pf ON pf.cod_alb=f.cod_alb AND pf.cod_faixa=f.cod LEFT OUTER JOIN Playlist pl ON pl.cod=pf.cod_play LEFT OUTER JOIN Album a ON a.cod=f.cod_alb WHERE f.descricao LIKE '%{}%' '''.format(Navigate.current_search) if self.callback: DBController.execute(query, self.callback()) else: DBController.execute(query) self.songsData = list(DBController.get()) def pack(self): for song in self.songsItems: song.unpack() self.songsItems = [] self.loadContent() if len(self.songsData): for song in self.songsData: def _(song): sec = timedelta(seconds=song[6]) dt = datetime(1, 1, 1) + sec titles = [ song[0], song[1], song[2], song[3], song[4], " ".join(song[5].split(' ')[0:5]) + '...', "%02d:%02d:%02d" % (dt.hour, dt.minute, dt.second) ] def gotoSong(_): Navigate.goto('_sg', song) self.songsItems.append( ListItem(self.songsList, titles, gotoSong)) _(song) else: self.songsItems.append( ListItem(self.songsList, ['Nenhuma música cadastrada.'], lambda _: _)) self.container.pack(expand=True, fill='both')