Exemplo n.º 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)
Exemplo n.º 2
0
 def editTagPress(button):
     if button == 'submit':
         result = app.getProperties('song tag selection')
         newTags = []
         for tag in result:
             if result[tag] is True:
                 newTags.append(db.getTag(tag))
         db.setSongTags(song, newTags)
         app.destroySubWindow('edit tags window')
Exemplo n.º 3
0
def tagOptionsWindow(tag):
    tag = db.getTag(tag)
    title = tag.name + ' tag options window'

    def press(button):
        if button == 'view songs':
            songs = tag.songs
            songNames = [song.name for song in songs]
            app.infoBox('songs', '\n'.join(songNames))
        elif button == 'remove':
            if app.yesNoBox('confirmation',
                            'are you sure you want to remove this tag?'):
                db.removeTag(tag)
                updateTagTable()
                app.destroySubWindow(title)

    def optionsContent():
        app.addButtons(['view songs', 'remove'], press)

    temporaryWindow(title, optionsContent)