Python ignoring while loop with True condition
Question: I'm writing a menu for a simple game, so I thought to use a while loop to let
the user choose his wanted option by clicking on it. While my program works
properly until this loop, it does not continue when reaching the line of the
following loop:

    
    
    pygame.mouse.set_visible(True)        # This is the last line processed.
    while True:                           # This line ist not processed.
        (curx,cury)= pygame.mouse.get_pos()
        screen.blit(cursor,(curx-17,cury-21))
        pygame.display.flip()
        # rating values of the cursor position and pressed mouse button below:
        (b1,b2,b3) = pygame.mouse.get_pressed()    #getting states of mouse buttons
        if (b1 == True or b2 == True or b3 == True): # "if one mouse button is pressed"
            (cx,cy) = pygame.mouse.get_pos()
            if (px <= curx <= px+spx and py <= cury <= py+spy):
                return (screen,0)
            elif (ox <= curx <= ox+sox and oy <= cury <= oy+soy):
                return (screen,1)
            elif (cx <= curx <= cx+scx and cy <= cury <= cy+scy):
                return (screen,2)
            else:
                return (screen,3)
        time.sleep(0.05)
    

I have already checked such things like wrong indentation.

BTW my interpreter (python.exe, Python 2.7.11) always does not respond after
reaching this line of the

    
    
    while True:
    

Because the question was asked in a deleted answer:

I had a print("") between every above shown line to find the problematic line.
As I wrote 4 lines above: The interpreter (and with it the debugger and bug
report) has crashed without any further response.

The whole code of this function is: # MAIN MENU def smenu
(screen,res,menuimg,cursor): #preset: x,y = res click = False

    
    
    print("preset") # TEST PART
    
    # Fontimports, needed because of non-standard font in use
    menu = pygame.image.load("menu.png")
    playGame = pygame.image.load("play.png")
    options = pygame.image.load("options.png")
    crdts = pygame.image.load("credits.png")
    
    print("Fontimport") # TEST PART
    
    
    #SIZETRANSFORMATIONS
    # setting of sizes
    smx,smy = int((y/7)*2.889),int(y/7)
    spx,spy = int((y/11)*6.5),int(y/11)
    sox,soy = int((y/11)*5.056),int(y/11)
    scx,scy = int((y/11)*5.056),int(y/11)
    
    print("setting of sizes") # TEST PART
    
    # setting real size of text 'n' stuff
    
    menu = pygame.transform.scale(menu,(smx,smy))
    playGame = pygame.transform.scale(playGame,(spx,spy))
    options = pygame.transform.scale(options, (sox,soy))
    crdts = pygame.transform.scale(crdts, (scx,scy))
    cursor = pygame.transform.scale(cursor,(41,33))
    
    print("actual size transformation") # TEST PART 
    
    #DISPLAY OF MENU
    # fixing positions
    mx, my = int((x/2)-((y/7)/2)*2.889),10 # position: 1. centered (x) 2. moved to the left for half of the text's length 3. positioned to the top(y), 10 pixels from edge
    px, py = int((x/2)-((y/11)/2)*6.5),int(y/7+10+y/10) # position: x like above, y: upper edge -"menu"'s height, -10, - height/10
    ox, oy = int((x/2)-((y/11)/2)*5.056),int(y/7+10+2*y/10+y/11)
    cx, cy = int((x/2)-((y/11)/2)*5.056),int(y/7+10+3*y/10+2*y/11)
    
    print("fixing positions") # TEST PART
    
    # set to display
    #screen.fill(0,0,0)
    screen.blit(menuimg,(0,0))
    screen.blit(menu,(mx,my)) 
    screen.blit(playGame,(px,py)) 
    screen.blit(options,(ox,oy))
    screen.blit(crdts,(cx,cy))
    pygame.display.flip()
    
    print("set to display") # TEST PART
    
    # request for input (choice of menu options)
    pygame.mouse.set_visible(True)
    print("mouse visible")  # TEST PART last processed line
    while (True):
        print("While-loop") # TEST PART
        curx,cury = pygame.mouse.get_pos()
        screen.blit(cursor,(curx-17,cury-21))
        pygame.display.flip()
        # decision value below
        (b1,b2,b3) = pygame.mouse.get_pressed() # getting mouse button's state
        if (b1 == True or b2 == True or b3 == True): # condition true if a buton is pressed
            (cx,cy) = pygame.mouse.get_pos()
            if (px <= curx <= px+spx and py <= cury <= py+spy):
                return (screen,0)
            elif (ox <= curx <= ox+sox and oy <= cury <= oy+soy):
                return (screen,1)
            elif (cx <= curx <= cx+scx and cy <= cury <= cy+scy):
                return (screen,2)
            else:
                return (screen,3)
        time.sleep(0.05)
    print("directly skipped")
    


Answer: I think that the problem is in the following line of your code:

    
    
    if (b1 == True or b2 == True or b3 == True):
    

This condition never becomes true so you are stuck into the while loop without
your function returning anything.

