コード例 #1
0
ファイル: srs.py プロジェクト: JacksonDCollins/PySrs
 def audPlay():
     img = ImageTk.PhotoImage(audDark)
     tWidget.img = img
     tWidget.configure(image=img, text='')
     audio.play(root.line, a=True)
     img = ImageTk.PhotoImage(audLight)
     tWidget.img = img
     tWidget.configure(image=img, text='')
コード例 #2
0
ファイル: srs.py プロジェクト: JacksonDCollins/PySrs
def afterAnswer(w, i, root):
    root.submit = False
    w.delete(0, len(w.get()))
    w["bg"] = "white"
    w["fg"] = "black"
    if not root.lineEdited:
        if not 'audio-' in root.line.split(',')[1].replace('commaChar', ','):
            audio.preload(root.line.split(','))
            audio.play(root.line.split(','))
        else:
            audio.play(root.line.split(','), a=True)
    root.update()
コード例 #3
0
 def listen(self):
     audio.preload(self.line)
     audio.play()
コード例 #4
0
 def listen(self):
     audio.preload(self.line)
     audio.startAudio()
     audio.play(self.line)
     audio.endAudio()
コード例 #5
0
ファイル: srs.py プロジェクト: JacksonDCollins/PySrs
def doLearnLesson(sentences, root, tWidget, eWidget, tagsWidget, cWidget):
    curdate = "{}/{}/{}".format(datetime.now().day,
                                datetime.now().month,
                                datetime.now().year)
    gotAnswer = False
    completed = []

    while len(sentences) > 0:
        random.shuffle(sentences)
        for n, i in enumerate(sentences):
            root.line = i.split(",")
            eWidget.delete(0, len(eWidget.get()))
            if not 'img-' in root.line[1].replace(
                    'commaChar', ',') and not 'audio-' in root.line[1].replace(
                        'commaChar', ','):
                tWidget.configure(text=root.line[1].replace("commaChar", ","),
                                  image=None)
                tWidget.unbind('<Button-1>')
            elif 'img-' in root.line[1].replace('commaChar', ','):
                imgFile = "{}\\{}\\{}\\{}\\{}\\{}".format(
                    consts.cwd(), consts.fname(), root.line[11], root.line[12],
                    consts.images(), root.line[1].replace('img-', ''))
                im = Image.open(imgFile)
                #im = im.resize(size=(50,50))
                img = ImageTk.PhotoImage(im)
                tWidget.img = img
                tWidget.configure(image=img, text='')
                tWidget.unbind('<Button-1>')
            elif 'audio-' in root.line[1].replace('commaChar', ','):
                img = ImageTk.PhotoImage(audLight)
                tWidget.img = img
                tWidget.configure(image=img, text='')

                def audPlay():
                    img = ImageTk.PhotoImage(audDark)
                    tWidget.img = img
                    tWidget.configure(image=img, text='')
                    audio.play(root.line, a=True)
                    img = ImageTk.PhotoImage(audLight)
                    tWidget.img = img
                    tWidget.configure(image=img, text='')

                tWidget.bind(
                    '<Button-1>', lambda x: threading.Thread(
                        target=audPlay, daemon=True).start())

            tagsWidget.configure(
                text=root.line[2].replace("commaChar", ",")
            ) if not root.line[2] == "none" else tagsWidget.configure(text="")

            if root.line[3] == 'no':
                cAnswerEntry = tk.Label(
                    root,
                    text=root.line[0].replace("commaChar",
                                              ",").replace(".", ""),
                    font=(lambda x: cAnswerEntry.cget('font'), 32),
                    width=50,
                    wraplength=1255)
                cAnswerEntry.grid(row=4, column=0, columnspan=2, rowspan=1)
                cWidget.set(0)
                root.update()
                if not 'audio-' in root.line[1].replace('commaChar', ','):
                    audio.preload(root.line)
                    audio.play(root.line)
                else:
                    img = ImageTk.PhotoImage(audDark)
                    tWidget.img = img
                    tWidget.configure(image=img, text='')
                    root.update()
                    audio.play(root.line, a=True)
                    img = ImageTk.PhotoImage(audLight)
                    tWidget.img = img
                    tWidget.configure(image=img, text='')
                root.line[3] = 'step0'
            else:
                cWidget.set(int(root.line[3].split("step")[1]))

            eWidget.focus()
            gotAnswer = False
            root.lineEdited = False
            userinput, time = waitForAnswer(gotAnswer, root, eWidget,
                                            root.line)
            try:
                root.editEntrytl.destroy()
            except:
                pass

            if userinput == root.line[0].lower().replace(".", ""):
                eWidget["bg"] = "lime green"
                eWidget["fg"] = "white"
                root.line[3] = "step{}".format(
                    int(root.line[3].split("step")[1]) + 1)
                cWidget.set(int(root.line[3].split("step")[1]))
                root.update()
                root.line = ','.join(root.line)
                sentences[n] = root.line
            else:
                eWidget["bg"] = "red"
                eWidget["fg"] = "white"
                root.line[3] = "no-step{}".format(
                    int(root.line[3].split("step")[1]))
                root.update()
                root.line = ','.join(root.line)
                sentences[n] = root.line

            cAnswerEntry.destroy()
            afterAnswer(eWidget, root.line.split(","), root)

            if not 'no' in root.line.split(",")[3]:
                if int(root.line.split(",")[3].split('step')[1]) == 6:
                    root.line = root.line.split(",")
                    root.line[3] = 'yes'
                    root.line[6] = curdate
                    root.line[8] = addDays(root.line)
                    root.line = ','.join(root.line)
                    completed.append(root.line)
                    del sentences[n]
            else:
                root.line = root.line.split(",")
                root.line[3] = root.line[3].split("no-")[1]
                root.line = ','.join(root.line)
                sentences[n] = root.line

    root.update()
    for widget in root.winfo_children():
        widget.destroy()
        root.update()
    text = tk.Label(root,
                    font=(lambda x: Label.cget('font'), 32),
                    text="lesson Done!")
    text.grid()
    root.update()

    mycsv.write(consts.workdoc(),
                mstr=completed,
                lesson=True,
                review=False,
                learn=True)