コード例 #1
0
class Window(QWidget):
    def __init__(self, width, height):
        super().__init__()
        self.height = height
        self.width = width
        self.index = 0
        self.leftBreak = 0
        self.rightBreak = 4
        self.bigPixList = []
        self.pixList = []
        self.label = []
        self.tagLabels = []
        self.bigLabel = QLabel(self)
        self.bigLabel.resize(self.width * 3 / 4, self.height * 3 / 4)
        self.bigLabel.move(self.width / 8, self.height / 8)
        self.bigLabel.hide()
        #adding buttons and textbox
        self.textBox = QLineEdit(self)
        self.textBox.setStyleSheet("color: rgb(255, 255, 255);")
        self.textBox.move(self.width / 6, self.height * 7 / 8)
        self.textBox.resize(150, self.height / 16)
        self.textBox.hide()
        self.tagButton = QPushButton('Add Tag', self)
        self.tagButton.setStyleSheet("background-color: rgb(125,125,125);")
        self.tagButton.move(self.width / 6, self.height * 15 / 16)
        self.tagButton.clicked.connect(self.tagClick)
        self.tagButton.hide()
        self.saveTagButton = QPushButton('Save All Tags', self)
        self.saveTagButton.setStyleSheet(
            "background-color: rgb(125, 125, 125);")
        self.saveTagButton.move(self.width / 6 + 75, self.height * 15 / 16)
        self.saveTagButton.clicked.connect(self.saveClick)
        self.saveTagButton.hide()
        self.setFocus()
        #item that holds the current string to be stored as tag
        self.currentString = []
        self.mode = 0
        #Sets up the warning message for too long strings
        self.warningMessage = QLabel(self)
        self.warningMessage.resize(self.width / 5, self.height / 16)
        self.warningMessage.setStyleSheet(
            "background-color: red; font: bold 14px")
        self.warningMessage.setText("String too long")
        self.warningMessage.move(self.width / 2, self.height * 7 / 8)
        self.warningMessage.hide()
        #setting up the sounds to use
        self.soundClick = QSoundEffect()
        self.soundClickWah = QSoundEffect()
        self.soundLoop = QSoundEffect()
        self.soundLoopWah = QSoundEffect()
        self.soundShift = QSoundEffect()
        self.soundShiftWah = QSoundEffect()
        self.soundClick.setSource(
            QUrl.fromLocalFile(os.path.join('sounds', 'PianoNote.wav')))
        self.soundClickWah.setSource(
            QUrl.fromLocalFile(os.path.join('sounds', 'PianoNoteWah.wav')))
        self.soundShift.setSource(
            QUrl.fromLocalFile(os.path.join('sounds', 'PianoMultiNote.wav')))
        self.soundShiftWah.setSource(
            QUrl.fromLocalFile(os.path.join('sounds',
                                            'PianoMultiNoteWah.wav')))
        self.soundLoop.setSource(
            QUrl.fromLocalFile(os.path.join('sounds', 'loop08.wav')))
        self.soundLoopWah.setSource(
            QUrl.fromLocalFile(os.path.join('sounds', 'loop08Wah.wav')))
        self.soundLoop.setLoopCount(QSoundEffect.Infinite)
        self.soundLoopWah.setLoopCount(QSoundEffect.Infinite)
        self.soundLoop.play()
        self.soundLoopWah.play()
        self.soundLoopWah.setMuted(1)
        self.initUI()

    #Adds the tag to the list triggered by clicking on the button only if the string is less than 11 characters, otherwise shows warning message
    def tagClick(self):
        tagValue = self.textBox.text()
        if (len(tagValue) < 11):
            self.currentString[self.index % len(self.pixList)] += (tagValue +
                                                                   "\n")
            self.tagLabels[self.index % len(self.pixList)].setText(
                self.currentString[self.index % len(self.pixList)])
            self.textBox.setText("")
            self.setFocus()
            self.warningMessage.hide()
        else:
            self.warningMessage.show()

    def saveClick(self):
        f = open('SavedTags.txt', 'w')
        f.truncate()
        for i in range(0, len(self.pixList), 1):
            f.write(self.tagLabels[i].text())
            f.write("#")

    def initUI(self):
        # title of window
        self.setWindowTitle('PyQt5 Main Window')
        # place window on screen at x=0, y=0
        self.setGeometry(0, 0, self.width, self.height)
        self.setStyleSheet('background-color: black')
        #sets up QLabels for later input
        for i in range(0, 5, 1):
            self.label.append(QLabel(self))
            self.label[i].move(self.width / 12 + i * self.width / 6,
                               self.height / 3)
            self.label[i].resize(self.width / 6, self.height / 6)
            self.label[i].setStyleSheet('background-color: red')
            if (i == 0):
                self.label[i].setStyleSheet('background-color: blue')
        #places pictures into pixmap array
        i = 0
        for file in os.listdir('data'):
            self.pixList.append(QPixmap(os.path.join('data', file)))
            self.bigPixList.append(QPixmap(os.path.join('data', file)))
            self.tagLabels.append(QLabel(self))
            self.currentString.append("")
            self.tagLabels[i].resize(self.width / 8, self.height)
            self.tagLabels[i].move(self.width * 7 / 8, 0)
            self.tagLabels[i].setStyleSheet(
                'border-color: grey; border-style: outset; border-width: 5px; font: bold 14px; color: white'
            )
            self.tagLabels[i].setAlignment(Qt.AlignTop)
            self.tagLabels[i].hide()
            if (self.pixList[i].height() > self.height / 6 - 10):
                self.pixList[i] = self.pixList[i].scaledToHeight(self.height /
                                                                 6 - 10)
            if (self.pixList[i].width() > self.width / 6 - 10):
                self.pixList[i] = self.pixList[i].scaledToWidth(self.width /
                                                                6 - 10)
            if (self.bigPixList[i].width() > self.width * 3 / 4):
                self.bigPixList[i] = self.bigPixList[i].scaledToWidth(
                    self.width * 3 / 4)
            if (self.bigPixList[i].height() > self.height * 3 / 4):
                self.bigPixList[i] = self.bigPixList[i].scaledToHeight(
                    self.height * 3 / 4)
            i = i + 1
        self.bigLabel.setAlignment(Qt.AlignCenter)
        self.bigLabel.setPixmap(self.bigPixList[0])
        #puts initial pixmaps into the designated qlabels
        for i in range(0, 5, 1):
            self.label[i].setPixmap(self.pixList[i])
            self.label[i].setAlignment(Qt.AlignCenter)
        self.show()
        self.loadTags()

    def loadTags(self):
        f = open('SavedTags.txt', 'r')
        tempString = f.read()
        j = 0
        for i in range(0, len(tempString), 1):
            if (tempString[i] != "#"):
                self.currentString[j] += tempString[i]
            else:
                self.tagLabels[j].setText(self.currentString[j])
                j = j + 1

    #Moves the pointer to the picture one to the left.  If it breaks the bounds, it will move the frame
    def moveIndexLeft(self):
        j = 0
        if (self.mode == 1):
            self.tagLabels[self.index % len(self.pixList)].hide()
            self.tagLabels[(self.index - 1) % len(self.pixList)].show()
        self.label[self.index % 5].setStyleSheet('background-color:red')
        self.index = self.index - 1
        if (self.index < self.leftBreak):
            self.leftBreak = self.leftBreak - 5
            self.rightBreak = self.rightBreak - 5
            for i in range(self.leftBreak, 1 + self.rightBreak, 1):
                self.label[j].setPixmap(self.pixList[i % len(self.pixList)])
                self.label[j].setAlignment(Qt.AlignCenter)
                j = j + 1
        self.label[self.index % 5].setStyleSheet('background-color: blue')
        self.bigLabel.setPixmap(self.bigPixList[self.index %
                                                len(self.pixList)])
        self.textBox.setText("")

    #Moves the pointer one picture to the right.  If it breaks the bounds of QLabel it will move the frame
    def moveIndexRight(self):
        j = 0
        if (self.mode == 1):
            self.tagLabels[self.index % len(self.pixList)].hide()
            self.tagLabels[(self.index + 1) % len(self.pixList)].show()
        self.label[self.index % 5].setStyleSheet('background-color: red')
        self.index = self.index + 1
        if (self.index > self.rightBreak):
            self.leftBreak = self.leftBreak + 5
            self.rightBreak = self.rightBreak + 5
            for i in range(self.leftBreak, 1 + self.rightBreak, 1):
                self.label[j].setPixmap(self.pixList[i % len(self.pixList)])
                self.label[j].setAlignment(Qt.AlignCenter)
                j = j + 1
        self.label[self.index % 5].setStyleSheet('background-color: blue')
        self.bigLabel.setPixmap(self.bigPixList[self.index %
                                                len(self.pixList)])
        self.textBox.setText("")

    #Zooms in on the specific picture selected and puts it into a 700 x 500 frame
    def zoomIn(self):
        self.mode = 1
        for i in range(0, 5, 1):
            self.label[i].hide()
        self.bigLabel.setAlignment(Qt.AlignCenter)
        self.bigLabel.show()
        self.tagButton.show()
        self.saveTagButton.show()
        self.textBox.show()
        self.tagLabels[self.index % len(self.pixList)].show()

    #Goes back to default view
    def zoomOut(self):
        self.mode = 0
        self.bigLabel.hide()
        for i in range(0, 5, 1):
            self.label[i].show()
        self.tagButton.hide()
        self.saveTagButton.hide()
        self.textBox.hide()
        self.tagLabels[self.index % len(self.pixList)].hide()

    #shifts the frame 5 pictures to the left
    def shiftLeft(self):
        if (self.mode == 1):
            self.tagLabels[self.index % len(self.pixList)].hide()
        self.label[self.index % 5].setStyleSheet('background-color:red')
        j = 0
        self.index = self.leftBreak - 1
        if (self.mode == 1):
            self.tagLabels[self.index % len(self.pixList)].show()
        self.leftBreak = self.leftBreak - 5
        self.rightBreak = self.rightBreak - 5
        for i in range(self.leftBreak, 1 + self.rightBreak, 1):
            self.label[j].setPixmap(self.pixList[i % len(self.pixList)])
            j = j + 1
        self.label[self.index % 5].setStyleSheet('background-color: blue')
        self.bigLabel.setPixmap(self.bigPixList[self.index %
                                                len(self.pixList)])
        self.textBox.setText("")

    #shifts the frame 5 pictures to the right
    def shiftRight(self):
        if (self.mode == 1):
            self.tagLabels[self.index % len(self.pixList)].hide()
        self.label[self.index % 5].setStyleSheet('background-color: red')
        j = 0
        self.index = self.rightBreak + 1
        if (self.mode == 1):
            self.tagLabels[self.index % len(self.pixList)].show()
        self.rightBreak = self.rightBreak + 5
        self.leftBreak = self.leftBreak + 5
        for i in range(self.leftBreak, 1 + self.rightBreak, 1):
            self.label[j].setPixmap(self.pixList[i % len(self.pixList)])
            j = j + 1
        self.label[self.index % 5].setStyleSheet('background-color: blue')
        self.bigLabel.setPixmap(self.bigPixList[self.index %
                                                len(self.pixList)])
        self.textBox.setText("")

    #all of the key inputs and their responses in functions
    def keyPressEvent(self, event):
        if (event.key() == 16777234):
            self.moveIndexLeft()
            if (self.mode == 0):
                self.soundClick.play()
            else:
                self.soundClickWah.play()
        if (event.key() == 16777236):
            self.moveIndexRight()
            if (self.mode == 0):
                self.soundClick.play()
            else:
                self.soundClickWah.play()
        if (event.key() == 16777235):
            self.zoomIn()
            self.soundLoop.setMuted(1)
            self.soundLoopWah.setMuted(0)
        if (event.key() == 16777237):
            self.zoomOut()
            self.soundLoopWah.setMuted(1)
            self.soundLoop.setMuted(0)
        if (event.key() == 44):
            self.shiftLeft()
            if (self.mode == 0):
                self.soundShift.play()
            else:
                self.soundShiftWah.play()
        if (event.key() == 46):
            self.shiftRight()
            if (self.mode == 0):
                self.soundShift.play()
            else:
                self.soundShiftWah.play()

    def mousePressEvent(self, QMouseEvent):
        if (QMouseEvent.y() < self.height / 7 * 8
                or QMouseEvent.y() > self.height / 15 * 16
                and QMouseEvent.x() < self.width / 6
                or QMouseEvent.x() > self.width / 3):
            self.setFocus()
        if (self.mode == 0):
            setPicTo = -1
            if (QMouseEvent.y() > self.height / 3 - 1
                    and QMouseEvent.y() < self.height / 2 + 1):
                if (QMouseEvent.x() > self.width / 12
                        and QMouseEvent.x() < self.width * 3 / 12 + 1):
                    setPicTo = 0
                if (QMouseEvent.x() > self.width * 3 / 12
                        and QMouseEvent.x() < self.width * 5 / 12 + 1):
                    setPicTo = 1
                if (QMouseEvent.x() > self.width * 5 / 12
                        and QMouseEvent.x() < self.width * 7 / 12 + 1):
                    setPicTo = 2
                if (QMouseEvent.x() > self.width * 7 / 12
                        and QMouseEvent.x() < self.width * 9 / 12 + 1):
                    setPicTo = 3
                if (QMouseEvent.x() > self.width * 9 / 12
                        and QMouseEvent.x() < self.width * 11 / 12 + 1):
                    setPicTo = 4
                if (setPicTo > -1):
                    self.label[self.index %
                               5].setStyleSheet('background-color:red')
                    self.mode = 1
                    self.index = self.leftBreak + setPicTo
                    self.label[self.index %
                               5].setStyleSheet('background-color:blue')
                    self.bigLabel.setPixmap(self.bigPixList[self.index %
                                                            len(self.pixList)])
                    for i in range(0, 5, 1):
                        self.label[i].hide()
                    self.bigLabel.setAlignment(Qt.AlignCenter)
                    self.bigLabel.show()
コード例 #2
0
class Window(QWidget):
 
    def __init__(self,width,height):
        super().__init__()
        self.height = height
        self.width = width
        #index for the navigation
        self.index = 0
        #index for changing the color of the selected image
        self.colorIndex = 0
        #determines when to load new images
        self.leftBreak = 0
        self.rightBreak = 4
        #large zoomed in image list
        self.bigPixList = []
        #thumbnail image list
        self.pixList = []
        #labels to store thumbnails
        self.label = []
        #labels to store tags
        self.tagLabels = []
        #big label for zoomed in image
        self.bigLabel = QLabel(self)
        self.bigLabel.resize(self.width * 3 / 4, self.height * 3 / 4)
        self.bigLabel.move(self.width / 8, self.height / 8)
        self.bigLabel.hide()
        #for saving all of the search images
        self.saveURL = ""
        #adding buttons and textbox
        self.textBox = QLineEdit(self)
        self.textBox.setStyleSheet("color: rgb(255, 255, 255);")
        self.textBox.move(self.width / 6, self.height * 7 / 8)
        self.textBox.resize(150,self.height / 16)
        self.textBox.hide()
        self.tagButton = QPushButton('Add Tag', self)
        self.tagButton.setStyleSheet("background-color: rgb(125,125,125);")
        self.tagButton.move(self.width / 6, self.height * 15 / 16)
        self.tagButton.clicked.connect(self.tagClick)
        self.tagButton.hide()
        self.saveTagButton = QPushButton('Save All Tags', self)
        self.saveTagButton.setStyleSheet("background-color: rgb(125, 125, 125);")
        self.saveTagButton.move(self.width / 6 + 75, self.height * 15 / 16)
        self.saveTagButton.clicked.connect(self.saveTagClick)
        self.saveTagButton.hide()
        self.searchBar = QLineEdit(self)
        self.searchBar.setStyleSheet("color: rgb(255, 255,255);")
        self.searchBar.move(self.width/6, self.height * 7 / 8)
        self.searchBar.resize(300, self.height / 16)
        self.setFocus()
        self.testButton  = QPushButton('Test', self)
        self.testButton.setStyleSheet("background-color: rgb(125, 125, 125);")
        self.testButton.move(self.width / 6, self.height * 15 / 16)
        self.testButton.clicked.connect(self.testClick)
        self.saveButton = QPushButton('Save', self)
        self.saveButton.setStyleSheet("background-color: rgb(125, 125, 125);")
        self.saveButton.move(self.width / 6 + 75, self.height * 15 / 16)
        self.saveButton.clicked.connect(self.saveClick)
        self.exitButton = QPushButton('Exit',self)
        self.exitButton.setStyleSheet("background-color: rgb(125, 125, 125);")
        self.exitButton.move(self.width / 6 + 150, self.height * 15 / 16)
        self.exitButton.clicked.connect(self.exitClick)
        self.deleteButton = QPushButton('Delete', self)
        self.deleteButton.setStyleSheet("background-color: rgb(125, 125, 125);")
        self.deleteButton.move(self.width / 6 + 225, self.height * 15 / 16)
        self.deleteButton.clicked.connect(self.deleteClick)
        self.searchButton = QPushButton('Search', self)
        self.searchButton.setStyleSheet("background-color: rgb(125, 125, 125);")
        self.searchButton.clicked.connect(self.searchClick)
        self.searchButton.move(self.width/6 +325, self.height * 29 / 32)
        self.searchResults = QLineEdit(self)
        self.searchResults.setStyleSheet("background-color: rgb(255, 255, 255);")
        self.searchResults.resize(25, self. height / 16)
        self.searchResults.move(self.width/6 + 425, self.height * 29 / 32)
        self.searchResults.setText("10")
        self.searchText = QLabel(self)
        self.searchText.resize(150, 50)
        self.searchText.move(self.width/6 + 455, self.height * 29 / 32)
        self.searchText.setText("Max Search Results")
        self.searchText.setStyleSheet("color: rgb(255, 255, 255);")
        #item that holds the current string to be stored as tag
        self.currentString = []
        self.mode = 0
        #Sets up the warning message for too long strings
        self.warningMessage = QLabel(self)
        self.warningMessage.resize(self.width / 5, self.height / 16)
        self.warningMessage.setStyleSheet("background-color: red; font: bold 14px")
        self.warningMessage.setText("String too long")
        self.warningMessage.move(self.width / 2, self.height * 7 / 8)
        self.warningMessage.hide()
        #setting up the sounds to use
        self.soundClick = QSoundEffect()
        self.soundClickWah = QSoundEffect()
        self.soundLoop = QSoundEffect()
        self.soundLoopWah = QSoundEffect()
        self.soundShift = QSoundEffect()
        self.soundShiftWah = QSoundEffect()
        self.soundClick.setSource(QUrl.fromLocalFile(os.path.join('sounds','PianoNote.wav')))
        self.soundClickWah.setSource(QUrl.fromLocalFile(os.path.join('sounds','PianoNoteWah.wav')))
        self.soundShift.setSource(QUrl.fromLocalFile(os.path.join('sounds','PianoMultiNote.wav')))
        self.soundShiftWah.setSource(QUrl.fromLocalFile(os.path.join('sounds','PianoMultiNoteWah.wav')))
        self.soundLoop.setSource(QUrl.fromLocalFile(os.path.join('sounds','loop08.wav')))
        self.soundLoopWah.setSource(QUrl.fromLocalFile(os.path.join('sounds','loop08Wah.wav')))
        self.soundLoop.setLoopCount(QSoundEffect.Infinite)
        self.soundLoopWah.setLoopCount(QSoundEffect.Infinite)
        self.soundLoop.play()
        self.soundLoopWah.play()
        self.soundLoopWah.setMuted(1)
        self.initUI()
    #Adds the tag to the list triggered by clicking on the button only if the string is less than 11 characters, otherwise shows warning message
    def tagClick(self):
        tagValue = self.textBox.text()
        if(len(tagValue) < 11):
            self.currentString[self.index % len(self.pixList)] += (tagValue + "\n")
            self.tagLabels[self.index % len(self.pixList)].setText(self.currentString[self.index % len(self.pixList)])
            self.textBox.setText("")
            self.setFocus()
            self.warningMessage.hide()
        else:
            self.warningMessage.show()
    def saveTagClick(self):
        f = open('SavedTags.txt','w')
        f.truncate()
        for i in range(0, len(self.pixList), 1):
            f.write(self.tagLabels[i].text())
            f.write("#")
        self.setFocus()
    #takes a URL entered into the search bar and adds an image to the two pixmap lists.  It also appends the URL onto the saved URLs string if the user wants to save them later    
    def testClick(self):
        path = self.searchBar.text()
        self.searchBar.setText("")
        self.saveURL = self.saveURL + path + "\n"
        url_data = urllib.request.urlopen(path).read()
        tmpPixmap = QPixmap()
        tmpPixmap.loadFromData(url_data)
        if(tmpPixmap.height() > self.height * 3 / 4):
            tmpPixmap = tmpPixmap.scaledToHeight(self.height * 3 / 4)
        if(tmpPixmap.width() > self.width * 3 / 4):
            tmpPixmap = tmpPixmap.scaledToWidth(self.width * 3 / 4)
        self.bigPixList.append(tmpPixmap)
        if(tmpPixmap.height() > self.height / 6 - 10):
            tmpPixmap = tmpPixmap.scaledToHeight(self.height / 6 - 10)
        if(tmpPixmap.width() > self.width / 6 - 10):
            tmpPixmap = tmpPixmap.scaledToWidth(self.width / 6 - 10)
        self.pixList.append(tmpPixmap)
        for i in range(-1,4,1):
            self.label[i + 1].setPixmap(self.pixList[i % len(self.pixList)])
        self.label[self.colorIndex].setStyleSheet('background-color: red')
        self.index = -1
        self.colorIndex = 0
        self.leftBreak = -1
        self.rightBreak = 3
        self.label[self.colorIndex].setStyleSheet('background-color: blue')
        self.tagLabels.append(self.tagLabels[i])
        self.tagLabels[-1 % len(self.pixList)].setText("")
        self.bigLabel.setPixmap(self.bigPixList[-1 % len(self.pixList)])
        self.setFocus()
    #saves all the URLS searched for into a text file separated by a new line
    def saveClick(self):
        f = open('SavedURLS.txt','w')
        f.truncate()
        f.write(self.saveURL)
        self.saveTags()
        self.setFocus()
    #exits the program
    def exitClick(self):
        sys.exit()
    #simply deletes the image out of the array and fixes it so that the images get truncated to fit
    def deleteClick(self):
        del self.pixList[self.index % len(self.pixList)]
        del self.bigPixList[self.index % len(self.pixList)]
        self.bigLabel.setPixmap(self.bigPixList[self.index % len(self.pixList)])
        for i in range(0, 5, 1):
            self.label[i].setPixmap(self.pixList[i + self.leftBreak])
        self.setFocus()
    #searches using the flickr API and json responses. Stores those images in the same two pixmap lists and appends the URLS to the saved urls string if the user wants to save them
    def searchClick(self):
        self.index = len(self.pixList)
        self.leftBreak = self.index
        self.rightBreak = self.index + 4
        self.label[self.colorIndex].setStyleSheet('background-color: red')
        self.colorIndex = 0
        self.label[0].setStyleSheet('background-color: blue')
        tempStr = self.searchBar.text()
        tempStr.replace(" ", "%20")
        self.searchBar.setText("")
        req = 'https://api.flickr.com/services/rest/'
        req = req + '?method=flickr.photos.search'
        req = req + '&per_page=' + self.searchResults.text()
        req = req + '&format=json&nojsoncallback=1'
        req = req + '&api_key=a0ab0abe9800e8352ae0364a9b595cd2'
        req = req + '&tags=' + tempStr
        jsonRespDict = requests.get(req).json()
        photoset = jsonRespDict['photos']
        for p in photoset['photo']:
            farm = p['farm']
            server = p['server']
            eyedee = p['id']
            secret = p['secret']
            tempStr = "http://farm" +str(farm) + ".static.flickr.com/" + str(server) + "/" + str(eyedee) + "_" + str(secret) + ".jpg"
            print(tempStr)
            self.saveURL = self.saveURL + tempStr + "\n"
            url_data = urllib.request.urlopen(tempStr).read()
            tmpPixmap = QPixmap()
            tmpPixmap.loadFromData(url_data)
            if(tmpPixmap.height() > self.height * 3 / 4):
                tmpPixmap = tmpPixmap.scaledToHeight(self.height * 3 / 4)
            if(tmpPixmap.width() > self.width * 3 / 4):
                tmpPixmap = tmpPixmap.scaledToWidth(self.width * 3 / 4)
            self.bigPixList.append(tmpPixmap)
            if(tmpPixmap.height() > self.height / 6 - 10):
                tmpPixmap = tmpPixmap.scaledToHeight(self.height / 6 - 10)
            if(tmpPixmap.width() > self.width / 6 - 10):
                tmpPixmap = tmpPixmap.scaledToWidth(self.width / 6 - 10)
            self.pixList.append(tmpPixmap)
            self.tagLabels.append(self.tagLabels[0])
        for i in range(self.index, len(self.pixList), 1):
            self.tagLabels[i].setText("")
        for i in range(self.index, self.index + 5, 1):
            self.label[i-self.index].setPixmap(self.pixList[i % len(self.pixList)])
        self.bigLabel.setPixmap(self.bigPixList[self.index % len(self.pixList)])
        self.setFocus()
    def initUI(self):
        # title of window
        self.setWindowTitle('PyQt5 Main Window')
        # place window on screen at x=0, y=0
        self.setGeometry(0, 0, self.width, self.height)
        self.setStyleSheet('background-color: black')
        #sets up QLabels for later input
        for i in range(0, 5, 1):
            self.label.append(QLabel(self))
            self.label[i].move(self.width / 12 + i * self.width / 6, self.height / 3)
            self.label[i].resize(self.width / 6, self.height / 6)
            self.label[i].setStyleSheet('background-color: red')
            if(i == 0):
                self.label[i].setStyleSheet('background-color: blue')
        #places pictures into pixmap array
        i = 0
        for file in os.listdir('data'):
            self.pixList.append(QPixmap(os.path.join('data', file)))
            self.bigPixList.append(QPixmap(os.path.join('data',file)))
            self.tagLabels.append(QLabel(self))
            self.currentString.append("")
            self.tagLabels[i].resize(self.width / 8, self.height)
            self.tagLabels[i].move(self.width * 7 / 8, 0)
            self.tagLabels[i].setStyleSheet('border-color: grey; border-style: outset; border-width: 5px; font: bold 14px; color: white')
            self.tagLabels[i].setAlignment(Qt.AlignTop)
            self.tagLabels[i].hide()
            if(self.pixList[i].height() > self.height / 6 - 10):
                self.pixList[i] = self.pixList[i].scaledToHeight(self.height / 6 - 10)
            if(self.pixList[i].width() > self.width / 6 - 10):
                self.pixList[i] = self.pixList[i].scaledToWidth(self.width / 6 - 10)
            if(self.bigPixList[i].width() > self.width*3/4 ):
                self.bigPixList[i] = self.bigPixList[i].scaledToWidth(self.width*3/4)
            if(self.bigPixList[i].height() > self.height*3/4):
                self.bigPixList[i] = self.bigPixList[i].scaledToHeight(self.height*3/4)
            i = i + 1
        self.bigLabel.setAlignment(Qt.AlignCenter)
        self.bigLabel.setPixmap(self.bigPixList[0])
        #puts initial pixmaps into the designated qlabels
        for i in range(0, 5, 1):
            self.label[i].setPixmap(self.pixList[i])
            self.label[i].setAlignment(Qt.AlignCenter)
        self.loadURLS()
        self.show()
        self.loadTags()
    #Loads URLS from the text file and places them into the pixmap array
    def loadURLS(self):
        f = open('SavedURLS.txt','r')
        tempString = f.read()
        self.savedURLS = tempString
        tempString2 = tempString.split("\n")
        for i in range(0, len(tempString2)-1, 1):
            url_data = urllib.request.urlopen(tempString2[i]).read()
            tmpPixmap = QPixmap()
            tmpPixmap.loadFromData(url_data)
            if(tmpPixmap.height() > self.height * 3 / 4):
                tmpPixmap = tmpPixmap.scaledToHeight(self.height * 3 / 4)
            if(tmpPixmap.width() > self.width * 3 / 4):
                tmpPixmap = tmpPixmap.scaledToWidth(self.width * 3 / 4)
            self.bigPixList.append(tmpPixmap)
            if(tmpPixmap.height() > self.height / 6 - 10):
                tmpPixmap = tmpPixmap.scaledToHeight(self.height / 6 - 10)
            if(tmpPixmap.width() > self.width / 6 - 10):
                tmpPixmap = tmpPixmap.scaledToWidth(self.width / 6 - 10)
            self.pixList.append(tmpPixmap)
            self.tagLabels.append(QLabel(self))
            self.currentString.append("")
            self.tagLabels[len(self.pixList)-1].resize(self.width / 8, self.height)
            self.tagLabels[len(self.pixList)-1].move(self.width * 7 / 8, 0)
            self.tagLabels[len(self.pixList)-1].setStyleSheet('border-color: grey; border-style: outset; border-width: 5px; font:bold 14px; color: white')
            self.tagLabels[len(self.pixList)-1].setAlignment(Qt.AlignTop)
            self.tagLabels[len(self.pixList)-1].hide()

    #loads all saved tags
    def loadTags(self):
        f = open('SavedTags.txt','r')
        tempString = f.read()
        j = 0
        for i in range(0, len(tempString), 1):
            if(tempString[i] != "#"):
                self.currentString[j]+=tempString[i]
            else:
                self.tagLabels[j].setText(self.currentString[j])
                j = j + 1
    #Moves the pointer to the picture one to the left.  If it breaks the bounds, it will move the frame
    def moveIndexLeft(self):
        j = 0
        if(self.mode == 1):
            self.tagLabels[self.index % len(self.pixList)].hide()
            self.tagLabels[(self.index - 1) % len(self.pixList)].show()
        self.label[self.colorIndex].setStyleSheet('background-color:red')
        self.colorIndex = self.colorIndex -1
        if(self.colorIndex < 0):
            self.colorIndex = 4
        self.index = self.index - 1
        if(self.index < self.leftBreak):
            self.leftBreak = self.leftBreak - 5
            self.rightBreak = self.rightBreak - 5
            for i in range(self.leftBreak, 1 + self.rightBreak, 1):
                self.label[j].setPixmap(self.pixList[i % len(self.pixList)])
                self.label[j].setAlignment(Qt.AlignCenter)
                j = j + 1
        self.label[self.colorIndex].setStyleSheet('background-color: blue')
        self.bigLabel.setPixmap(self.bigPixList[self.index % len(self.pixList)])
        self.textBox.setText("")
    #Moves the pointer one picture to the right.  If it breaks the bounds of QLabel it will move the frame
    def moveIndexRight(self):
        j = 0
        if(self.mode == 1):
            self.tagLabels[self.index % len(self.pixList)].hide()
            self.tagLabels[(self.index + 1) % len(self.pixList)].show()
        self.label[self.colorIndex].setStyleSheet('background-color: red')
        self.colorIndex = self.colorIndex + 1
        if(self.colorIndex > 4):
            self.colorIndex = 0
        self.index = self.index + 1
        if(self.index > self.rightBreak):
            self.leftBreak = self.leftBreak + 5
            self.rightBreak = self.rightBreak + 5
            for i in range(self.leftBreak, 1 + self.rightBreak, 1):
                self.label[j].setPixmap(self.pixList[i % len(self.pixList)])
                self.label[j].setAlignment(Qt.AlignCenter)
                j = j + 1
        self.label[self.colorIndex].setStyleSheet('background-color: blue')
        self.bigLabel.setPixmap(self.bigPixList[self.index % len(self.pixList)])
        self.textBox.setText("")
    #Zooms in on the specific picture selected and puts it into a 700 x 500 frame    
    def zoomIn(self):
        self.mode = 1
        for i in range(0, 5, 1):
            self.label[i].hide()
        self.bigLabel.setAlignment(Qt.AlignCenter)
        self.bigLabel.show()
        self.tagButton.show()
        self.saveTagButton.show()
        self.textBox.show()
        self.tagLabels[self.index % len(self.pixList)].show()
        self.searchBar.hide()
        self.testButton.hide()
        self.saveButton.hide()
        self.exitButton.hide()
        self.deleteButton.hide()
        self.searchButton.hide()
        self.searchResults.hide()
        self.searchText.hide()
    #Goes back to default view
    def zoomOut(self):
        self.mode = 0
        self.bigLabel.hide()
        for i in range(0, 5, 1):
            self.label[i].show()
        self.tagButton.hide()
        self.saveTagButton.hide()
        self.textBox.hide()
        self.tagLabels[self.index % len(self.pixList)].hide()
        self.searchBar.show()
        self.testButton.show()
        self.saveButton.show()
        self.exitButton.show()
        self.deleteButton.show()
        self.searchButton.show()
        self.searchResults.show()
        self.searchText.show()
    #shifts the frame 5 pictures to the left
    def shiftLeft(self):
        if(self.mode == 1):
            self.tagLabels[self.index % len(self.pixList)].hide()
        self.label[self.colorIndex].setStyleSheet('background-color:red')
        j = 0
        self.colorIndex = 0
        self.index = self.leftBreak - 5
        if(self.mode == 1):
            self.tagLabels[self.index % len(self.pixList)].show()
        self.leftBreak = self.leftBreak - 5
        self.rightBreak = self.rightBreak - 5
        for i in range(self.leftBreak, 1 + self.rightBreak, 1):
            self.label[j].setPixmap(self.pixList[i % len(self.pixList)])
            j = j + 1
        self.label[0].setStyleSheet('background-color: blue')
        self.bigLabel.setPixmap(self.bigPixList[self.index % len(self.pixList)])
        self.textBox.setText("")
    #shifts the frame 5 pictures to the right
    def shiftRight(self):
        if(self.mode == 1):
            self.tagLabels[self.index % len(self.pixList)].hide()
        self.label[self.colorIndex].setStyleSheet('background-color: red')
        self.colorIndex = 0
        j = 0
        self.index = self.rightBreak + 1
        if(self.mode == 1):
            self.tagLabels[self.index % len(self.pixList)].show()
        self.rightBreak = self.rightBreak + 5
        self.leftBreak = self.leftBreak + 5
        for i in range(self.leftBreak, 1 + self.rightBreak, 1):
            self.label[j].setPixmap(self.pixList[i % len(self.pixList)])
            j = j + 1
        self.label[0].setStyleSheet('background-color: blue')
        self.bigLabel.setPixmap(self.bigPixList[self.index % len(self.pixList)])
        self.textBox.setText("")
    #all of the key inputs and their responses in functions
    def keyPressEvent(self, event):
        if(event.key() == 16777234):
            self.moveIndexLeft()
            if(self.mode == 0):
                self.soundClick.play()
            else:
                self.soundClickWah.play()
        if(event.key() == 16777236):
            self.moveIndexRight()
            if(self.mode == 0):
                self.soundClick.play()
            else:
                self.soundClickWah.play()
        if(event.key() == 16777235):
            self.zoomIn()
            self.soundLoop.setMuted(1)
            self.soundLoopWah.setMuted(0)
        if(event.key() == 16777237):
            self.zoomOut()
            self.soundLoopWah.setMuted(1)
            self.soundLoop.setMuted(0)
        if(event.key() == 44):
            self.shiftLeft()
            if(self.mode == 0):
                self.soundShift.play()
            else:
                self.soundShiftWah.play()
        if(event.key() == 46):
            self.shiftRight()
            if(self.mode == 0):
                self.soundShift.play()
            else:
                self.soundShiftWah.play()
    def mousePressEvent(self, QMouseEvent):
        if(QMouseEvent.y() < self.height / 7 * 8 or QMouseEvent.y() > self.height / 15 * 16 and QMouseEvent.x() < self.width / 6 or QMouseEvent.x() > self.width / 3):
            self.setFocus()
        if(self.mode == 0):
            setPicTo = -1
            if(QMouseEvent.y() > self.height / 3 - 1 and QMouseEvent.y() < self.height / 2 + 1):
                if(QMouseEvent.x() > self.width / 12 and QMouseEvent.x() < self.width * 3 / 12 + 1):
                    setPicTo = 0
                if(QMouseEvent.x() > self.width * 3 / 12  and QMouseEvent.x() < self.width * 5 / 12 + 1):
                    setPicTo = 1
                if(QMouseEvent.x() > self.width * 5 / 12  and QMouseEvent.x() < self.width * 7 / 12 + 1):
                    setPicTo = 2
                if(QMouseEvent.x() > self.width * 7 / 12  and QMouseEvent.x() < self.width * 9 / 12 + 1):
                    setPicTo = 3
                if(QMouseEvent.x() > self.width * 9 / 12  and QMouseEvent.x() < self.width * 11 / 12 + 1):
                    setPicTo = 4
                if(setPicTo > -1):
                    self.label[self.index % 5].setStyleSheet('background-color:red')
                    self.mode = 1
                    self.index = self.leftBreak + setPicTo
                    self.colorIndex = setPicTo
                    self.label[self.index % 5].setStyleSheet('background-color:blue')
                    self.bigLabel.setPixmap(self.bigPixList[self.index % len(self.pixList)])
                    for i in range(0, 5, 1):
                        self.label[i].hide()
                    self.bigLabel.setAlignment(Qt.AlignCenter)
                    self.bigLabel.show()