Почему моя переменная не подключается к моей строке, когда я использую команду Button? - PullRequest
0 голосов
/ 26 апреля 2020

Я пытаюсь сделать тест, который будет печатать разные вопросы в учебнике, когда кнопка нажимается 1-5 раз. Я указал, что строка будет получена из текстового поля, и я попытался сделать так, чтобы он возвращал любой текст, который был напечатан в этом текстовом поле, и использовал его в качестве стимула для вставки следующего вопроса, а не просто нажатия кнопки. , Я не знаю, правильно ли я создал функцию вызова для этого, и насколько я знаю, он не распознает ни одну из переменных в функции Bully как часть команды, несмотря на то, что я сделал и мою строковую функцию, и мой вопрос переменные оба gloabl заявления. Это мой код, если он помогает ...

'' из Tkinter import * import matplotlib.pyplot как plt
root = Tk ()
Bully = '' Yeah = '' Вопрос1 = 0 Вопрос2 = 0 Вопрос3 = 0 Вопрос4 = 0 Вопрос5 = 0

#Text boxes for question
textQ = Text(root, width= 30, height= 7, background= '#000080')
textQ.place(x=120, y=470)

    

#THE START BUTTON
ButtonStart = Button(root, width=4, height = 1, text = 'Enter', command = EnterCall, bg= '#000000')
ButtonStart.place(x=390, y = 450)

    
def OWO(text2ins):#the text to be inserted 
        Bully = textQ.config(state=NORMAL)
        #need different ones for red and green boxes
        textQ.delete(1.0, 'end-1c')
        textQ.insert('end-1c', text2ins)
        textQ.config(state=DISABLED)
    #This makes it so that once the user receives their prediction, they will not be able to edit the contents of the box; goes from normal to disabled
#need another textbox for the score; should be connected to answer call
contents = textQ.get(1.0, 'end-1c')

   

    
def EnterCall():


    global Question1
    global Question2
    global Question3
    global Question4
    global Question5

    

    global textQ, Bully

    Bully = str(textQ.get('1.0', 'end-1c'))

    print Bully
if Bully == '' and Question1 == 0 :
    OWO('OOHHH no a bully aproaches')
    UWU('Wrong1')
    WOW('Right1')
    Question1 += 1

elif Bully == '' and Question1 != 0 :
    OWO('WHAT STEPS DO YOU TAKE')
    UWU('Wrong2')
    WOW('Right2')
    Question2 += 1

elif Bully == 'WHAT STEPS DO YOU TAKE' and Question3 == 0:
    OWO('HOLY COW')
    UWU('Wrong3')
    WOW('Right3')
    Question3 += 1

    
elif Bully == 'HOLY COW' and Question4 == 0:
    OWO('Soon, I shall type real content')
    UWU('Wrong4')
    WOW('Right4')
    Question4 += 1

    
elif Bully == 'Soon, I shall type real content' and Question5 == 0:
    OWO('Yay last question')
    UWU('Wrong5')
    WOW('Right5')
    Question5 += 1

root.geometry(800x800)
root.mainloop()

'' '

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...