[Python] how to keep the focus of curser in terminal after opening a url through...

Discussão em 'Python' iniciado por Stack, Agosto 27, 2025.

  1. Stack

    Stack Membro Participativo

    I'm on windows using vscode,

    while True:
    command = input("enter to next, 0 to append and next (or type 'e' to quit): ")

    if command.lower() == 'e':
    print("Exiting the program.")
    break

    if n >= len(name):
    print("No more destinations left.")
    break
    if command == '0':
    newlist.append(name[n] + "\n")
    print(f"Appended: {name[n]}")

    destination = name[n]
    n += 1

    # Build Google Maps directions link safely
    url = "https://www.google.com/maps/dir/" + urllib.parse.quote(origin) + "/" + urllib.parse.quote(destination)

    # Open in browser
    #webbrowser.open(url, new=2) # 2 = open in new tab if possible
    webbrowser.open_new_tab(url)


    Opening google maps through python code, working but focus of my curser is not staying in terminal, i have to manually bring focus back to terminal for next command.

    Continue reading...

Compartilhe esta Página