我試圖從Tkinter的執行蟒蛇3文件,當我點擊一個按鈕如何Tkinter的執行Python 3的程序一個鍵
Tkinter的代碼
import tkinter as tk
import subprocess as sub
WINDOW_SIZE = "600x400"
root = tk.Tk()
root.geometry(WINDOW_SIZE)
tk.Button(root, text="Create Motion!", command=lambda: sub.call('home/pi/motion1.py')).pack()
但收到錯誤時我運行程序
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python3.5/tkinter/__init__.py", line 1562, in __call__
return self.func(*args)
File "/home/pi/AnimationGUI.py", line 11, in <lambda>
tk.Button(root, text="Create Motion!", command=lambda: sub.call('motion1.py')).pack()
File "/usr/lib/python3.5/subprocess.py", line 247, in call
with Popen(*popenargs, **kwargs) as p:
File "/usr/lib/python3.5/subprocess.py", line 676, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.5/subprocess.py", line 1282, in _execute_child
raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'motion1.py'
嗨,感謝您的迴應,我以爲是我給了我做錯了什麼的絕對路徑? – Coyney22
也許你在「home/pi/motion1.py」 –
前需要一個「/」,因爲它解決了那個部分,但是現在獲得[Errno 13]權限被拒絕了? – Coyney22