[Python] Can not run python script outside of visual studio 2022, works fine inside visual...

Discussão em 'Python' iniciado por Stack, Outubro 23, 2024.

  1. Stack

    Stack Membro Participativo

    When i run the Python script outside visual studio 2022 the black prompt immidiately closes again but when i run it inside visual studio it works as intended.

    So far i am just trying to create a interface where you can choose to perform actions by selecting with your arrow keys.

    I have tried running the script thru cmd and with both python 3.10 and 3.7.

    from turtle import clearscreen
    import keyboard
    import time
    import os
    import colorconsole
    import sys



    i = 0
    def clear():
    os.system("cls")

    def menue():
    if i == 0:
    print(" >", end="")
    print("bootloader programming")
    if i == 1:
    print(" >", end="")
    print("system controller programming")
    if i == 2:
    print(" >", end="")
    print("options")

    menue()

    while True:
    def bootloader():
    print("what bootloader do you require?")

    def systemController():
    print("what unit do you wish to program?")
    if keyboard.is_pressed('down'):
    i = i + 1
    if i == 3:
    i = 0
    clear()
    menue()
    elif keyboard.is_pressed('up'):
    i = i - 1
    if i == -1:
    i = 2
    clear()
    menue()
    elif keyboard.is_pressed('enter'):
    if i == 0:
    bootloader()
    if i == 1:
    systemController()
    if i == 2:
    options()

    time.sleep(0.1)


    def comConf():
    print("input desired COM-port and press enter")
    comDesire = input()

    def lockedConf():
    passwordInput = input("password:")
    if passwordInput == "supersecretpassword":
    print("welcome admin person")

    def options():
    i2 = 0

    def optionsMenue():
    if i2 == 0:
    print(" >", end="")
    print("back")
    if i2 == 1:
    print(" >", end="")
    print("select COM-port")
    if i2 == 2:
    print(" >", end="")
    print("locked config")

    optionsMenue()
    time.sleep(1)
    while True:
    if keyboard.is_pressed('down'):
    i2 = i2 + 1
    if i2 == 3:
    i2 = 0
    clear()
    optionsMenue()
    elif keyboard.is_pressed('up'):
    i2 = i2 - 1
    if i2 == -1:
    i2 = 2
    clear()
    optionsMenue()
    if keyboard.is_pressed('enter'):
    if i2 == 0:
    clear()
    menue()
    break
    if i2 == 1:
    comConf()
    if i2 == 2:
    lockedConf()
    time.sleep(0.1)

    Continue reading...

Compartilhe esta Página