我使用了在while循环中使用函数的tkinter。我应该编写函数的结尾以返回while循环

时间:2016-07-02 22:44:02

标签: python loops while-loop

没有错误,但它没有返回while循环并重复函数内部的任务(正确答案或错误答案加1)我也尝试过继续'和&# 39;返回'在功能结束时。

while yes_r == 1 and condition1 is True: # the while loop


  for i in a:   # the iteration in which it uses texts
    b = int(i)
    if b == 2:   
       condition1 = False

    title= str(["is "+RA[b]+ Q[b]])


    if RA[b].strip() == A[b].strip():   
        res = True
    else:
        res = False

重复该功能内的任务(每次按下该按钮时,正确答案或错误答案加1)

    def Result_true(): # this is used for the first button
        global TrA
        global TQ
        global res  

        if res == True :

          TQ.set ( TQ.get ( ) + 1 )
          TrA.set ( TrA.get ( ) + 1 )
        else:
          TQ.set ( TQ.get ( ) + 1 )
                        # I add some codes here but I failed to succeed

    def Result_false(): # this is used for the second button and 

        global TrA
        global TQ
        global res   


        if res == True :
          TQ.set ( TQ.get ( ) + 1 )

        else:

          TQ.set ( TQ.get ( ) + 1 )
          TrA.set ( TrA.get ( ) + 1 )

#this section uses tkinter, I need to return back to the while loop after   
   #going into the functions via widgets

    b1 = Button(app02, text = " right!", width = 23, fg="green",command= Result_true).pack(side = 'right', padx = 0, pady = 0) 
    b2 = Button(app02, text = " wrong!", width = 23, fg="red", command=Result_false).pack(side = 'left', padx = 0, pady = 0)

0 个答案:

没有答案