Beispiel #1
0
    def exportResource(self):
        textForXML = self.puzzlenamelabel.text().replace('"', '').replace(' ', '')
        resourceData = dnbhl.getPuzzleInformation(textForXML)
        print(textForXML)
        with open('temp', 'rb') as file:
            data = file.read()

        
        fileToOpen = QtWidgets.QFileDialog.getSaveFileName(self, "Save Resource", '')[0]

        with open(fileToOpen, 'wb') as file:
            file.write(data)
Beispiel #2
0
 def checkForPuzzle(self):
     text = self.answerArea.text()
     textEdited = self.answerArea.text().replace(' ', '').upper()
     isvalid = dnbhl.getPuzzleInformation(textEdited)
     if isvalid == 'NotFoundError':
         self.answerArea.setText('')
     
         '''self.shakeAnim = QtCore.QPropertyAnimation(self, 'geometry')
         self.shakeAnim.setDuration(1000)
         print(self.answerArea.geometry())
         self.shakeAnim.setStartValue(self.geometry())
         self.shakeAnim.setEndValue(QtCore.QRect(250, 250, 100, 30))
         self.shakeAnim.start()'''
         
     else:
         self.setToPuzzle()
Beispiel #3
0
    def setToPuzzle(self):
        self.hintButton.show()
        self.answerArea.hide()
        self.loadingBar.show()
        '''for i in range(0,30): 
            self.loadingBar.setValue(i)
            time.sleep(0.01)'''
        self.loadingBar.setRange(0,0)
        self.printAction.setEnabled(False)
        textForXML = self.answerArea.text().upper().replace(' ', '')
        textCopy2 = '"' + self.answerArea.text().upper() + '"'
        self.puzzlenamelabel.setText(textCopy2)
        puzzleinfo = dnbhl.getPuzzleInformation(textForXML)
        if puzzleinfo['type'] == 'text':
            self.label.setText(puzzleinfo['resource'])
        
        elif puzzleinfo['type'] == 'img':
            self.printAction.setEnabled(True)
            if puzzleinfo['resource'][-4:] == '.gif':
                self.movie = QtGui.QMovie(puzzleinfo['resource'], QtCore.QByteArray(), self)
                self.label.setMovie(self.movie)
                self.movie.start()
            else:
                self.label.setPixmap(QtGui.QPixmap('temp'))

        elif puzzleinfo['type'] == 'vid':
            self.movie = QtGui.QMovie('temp', QtCore.QByteArray(), self)
            self.label.setMovie(self.movie)
            self.movie.start()
        
        elif puzzleinfo['type'] == 'sound':
            self.label.setText(puzzleinfo['resource'][1])
            if puzzleinfo['resource'][0][-4:] == '.wav':
                QtMultimedia.QSound.play('temp')
            else:
                pipes = dict(stdin=PIPE, stdout=PIPE, stderr=PIPE)
                subprocess.Popen(["mplayer", "sound.m4a"], **pipes)
                mplayer.communicate(input=b">")

        self.loadingBar.hide()
        self.answerArea.show()
        self.answerArea.setText('')
        

        self.hint = puzzleinfo['hint']