예제 #1
0
 def submit(button):
     if button == 'submit':
         # bangericity
         minBangericity = float(app.getEntry('minimum bangericity'))
         maxBangericity = float(app.getEntry('maximum bangericity'))
         # validate bangericities
         if not minBangericity < maxBangericity:
             app.errorBox(
                 'invalid bangericities', 'minimum bangericity\
              must be less than maximum bangericity')
             return None
         # include logic
         andLogic = app.getCheckBox('use AND logic on includes')
         # tags
         newIncludedTags = []
         newExcludedTags = []
         includedTagDict = app.getProperties('included tags')
         excludedTagDict = app.getProperties('excluded tags')
         ##### left off here investigating bug where you can't edit then add
         # also label entries
         # figure out what the new tags will be
         for tag in includedTagDict:
             if includedTagDict[tag] is True:
                 newIncludedTags.append(db.getTag(tag))
             if excludedTagDict[tag] is True:
                 newExcludedTags.append(db.getTag(tag))
         # name
         if playlist is None:
             name = app.getEntry('name')
             # validate name
             if name == '':
                 app.errorBox('invalid name',
                              'playlist must have a name')
                 return None
             existingPlaylistNames = [
                 playlist.name for playlist in db.getAllPlaylists()
             ]
             if name in existingPlaylistNames:
                 app.errorBox(
                     'duplicate name', 'a playlist with that\
                  name already exists')
                 return None
             # create playlist
             db.addPlaylist(name, newIncludedTags, newExcludedTags,
                            minBangericity, maxBangericity, andLogic)
             showPlaylistSongs(name)
             updatePlaylistTable()
             app.destroySubWindow(title)
         else:
             # edit playlist
             playlist.includedTags = newIncludedTags
             playlist.excludedTags = newExcludedTags
             playlist.minBangericity = minBangericity
             playlist.maxBangericity = maxBangericity
             playlist.andLogic = andLogic
             showPlaylistSongs(playlist)
             updatePlaylistTable()
             app.destroySubWindow(title)
예제 #2
0
def updatePlaylistTable():
    playlists = db.getAllPlaylists()
    tableArr = [[playlist.name] for playlist in playlists]
    tableArr.sort()
    app.replaceAllTableRows('playlist table', tableArr)
예제 #3
0
    db.addTag(name)
    updateTagTable()


with app.tabbedFrame('tabs'):
    with app.tab('songs'):
        songs = db.getAllSongs()
        tableArr = [[song.name, song.bangericity] for song in songs]
        tableArr.sort()
        app.addTable('song table', [['Name', 'Bangericity']] + tableArr,
                     colspan=3,
                     addRow=addSong,
                     showMenu=True,
                     action=songAction)
    with app.tab('playlists'):
        playlists = db.getAllPlaylists()
        tableArr = [[playlist.name] for playlist in playlists]
        tableArr.sort()
        app.addTable('playlist table', [['Name']] + tableArr,
                     colspan=3,
                     showMenu=True,
                     action=playlistAction,
                     addRow=playlistForm)
    with app.tab('tags'):
        tags = db.getAllTags()
        tableArr = [[tag.name] for tag in tags]
        tableArr.sort()
        app.addTable('tag table', [['Name']] + tableArr,
                     colspan=3,
                     showMenu=True,
                     action=tagAction,