เรียกใช้สคริปต์ Python ติดตามผล (Tkinter Interface) หลังจากดำเนินการ

หลังจากป้อนรหัสผ่านในสคริปต์ Python เริ่มต้น ฉันกำลังพยายามเปิดสคริปต์ Python ติดตามผลเนื่องจากรหัสผ่านถูกต้อง ฉันได้สร้าง Tkinter เพื่อให้ผู้ใช้ป้อนรหัสผ่าน

ฉันรู้ว่าฉันสามารถนำเข้าฟังก์ชันและสคริปต์ได้ แต่นี่ไม่ใช่เส้นทางที่ฉันพยายามจะลงไป

ขั้นตอน:

1) ใส่รหัสผ่านในช่องป้อนข้อมูล จากนั้นกดส่ง

2a) หากไม่ถูกต้อง กล่องโต้ตอบจะปรากฏขึ้น

2b) หากรหัสผ่านถูกต้อง สคริปต์ Python อื่นจะทำงาน


แก้ไข: ขอบคุณ Jonathan สำหรับการตอบกลับของคุณ!
โครงสร้างของโซลูชันที่ฉันกำลังค้นหาแบ่งออกเป็นสองส่วน ดังตัวอย่างด้านล่างนี้


Script1.py------------
window = Tk()
button = Button(window, text='OK')
button.config(width=5, height=2, command=somefunctionacceptingordeclining)
<br/>
def somefunctionacceptingordeclining():
    if something == something:
        LaunchScript2("C:/Users/User/Documents/Code/Script2.py")
<br/>
window.mainloop()
<br/>
Script2.py-------------------
<br/>
window = Tk()
def dostuff(x, y, z)

person Tom Kim    schedule 06.04.2019    source แหล่งที่มา


คำตอบ (1)


คำถามที่ดี. ฉันไม่รู้ว่าโค้ดของคุณหน้าตาเป็นอย่างไร ดังนั้นบางทีคุณอาจให้มาก็ได้ แต่สิ่งที่ฉันคิดว่าคุณต้องการคือ:


window = Tk()

# set up password 

#button which may accept the password/username
button = Button(window, text='OK')
button.config(width=5, height=2, command=somefunctionacceptingordeclining)

def somefunctionacceptingordeclining():
    if something == something:
        window.quit() #this closes the current window and resumes execution 
                      #where i put RESUME

window.mainloop()
# RESUME:

#by importing the script below here you execute it when the window is closed.
import someotherscript

หวังว่ามันจะช่วยได้!

person jonathan    schedule 06.04.2019
comment
ไม่ค่อยมีประสบการณ์กับ Stack มากนัก/ไม่รู้วิธีแก้ไขความคิดเห็นเพื่อเพิ่มโค้ดที่ดึงดูดสายตา ดังนั้นฉันจึงแก้ไขโพสต์ต้นฉบับด้วยสิ่งที่ฉันกำลังมองหา :) หวังว่าจะมีวิธีแก้ไข - person Tom Kim; 07.04.2019
comment
ฉันเข้าใจถูกต้องหรือไม่ว่าคุณต้องการฟังก์ชันที่รันสคริปต์หลามอื่น - person jonathan; 07.04.2019
comment
ใช่ ฟังก์ชันที่สามารถรันสคริปต์อื่นได้ - person Tom Kim; 24.09.2019