0
我有一個項目在工作,我們真正的開發人員沒有時間來處理我需要的東西,所以我正在創建我的第一個GUI。tkinter按鈕不打開所有批處理文件
它有兩個按鈕。點擊後,他們運行一個批處理文件。批處理文件運行註冊表文件,並運行軟件可執行文件。它正常工作時,我的測試,但蝙蝠只跑了迴音說...當我更換該批處理文件與下面的批次的「Hello World!」:
start /d "C:\Cogent\cls.chd\" cls.reg
SLEEP 5
start /d "C:\Cogent\cls.chd\bin\" CLSMain.exe
我運行相同的.py文件我得到以下錯誤:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python33\lib\subprocess.py", line 1112, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python33\lib\tkinter\__init__.py", line 1475, in __call__
return self.func(*args)
File "C:\Users\A32DZZZ\Desktop\LivescanMonrowFinal.py", line 31, in run1
process=subprocess.Popen("launch.bat", cwd=r"C:\\Cogent\\cls.chd")
File "C:\Python33\lib\subprocess.py", line 824, in __init__
restore_signals, start_new_session)
File "C:\Python33\lib\subprocess.py", line 1118, in _execute_child
raise WindowsError(*e.args)
FileNotFoundError: [WinError 2] The system cannot find the file specified"
任何人都可以告訴我我顯然不理解嗎?我的圖形用戶界面如下:
from tkinter import *
import subprocess
master = Tk()
master.title("Monroe Livescan Version Selector")
master.geometry("400x166")
#Menu construction
menubar=Menu(master)
filemenu = Menu(menubar,tearoff = 0)
filemenu.add_command(label="Close")
menubar.add_cascade(label="File",menu=filemenu)
helpmenu = Menu(menubar,tearoff = 0)
helpmenu.add_command(label="Help Docs")
helpmenu.add_command(label="About")
menubar.add_cascade(label="Help",menu=helpmenu)
master.config(menu=menubar)
#Define run function for first Livescan package.
def run1():
process=subprocess.Popen("launch.bat", cwd=r"C:\\Cogent\\cls.chd")
def run2():
process=subprocess.Popen("launch.bat", cwd=r"C:\\Cogent\\cls.iafis")
#Define the button geometry and commands to run.
b1 = Button(master, text='Child ID', command=run1)
b1.pack(padx=5, pady=5)
b1.config(height=4, width=45)
b2 = Button(master, text='IAFIS', command=run2)
b2.pack(padx=5, pady=5)
b2.config(height=4, width=45)
mainloop()
你爲什麼認爲這是一個tkinter問題?如果直接運行'subprocess',會發生什麼? – jonrsharpe 2014-10-16 12:46:15
看起來像差不多相同的錯誤。我不認爲它是特定於tkinter,按鈕的工作和gui是好的。我猜這個子進程命令有問題,但我不知道它究竟是什麼。 – Thr1llhouse 2014-10-16 15:09:00
在這種情況下,您可能會剝離與GUI有關的所有內容。看看http://stackoverflow.com/help/mcve和http://ericlippert.com/2014/03/05/how-to-debug-small-programs/ – jonrsharpe 2014-10-16 15:09:59