저는 직장에서 프로젝트를 진행하고 있으며 실제 개발자는 필요한 시간을 갖지 않아서 첫 번째 GUI를 만들었습니다.tkinter 버튼이 모든 배치 파일을 열지 않습니다.
두 개의 버튼이 있습니다. 클릭하면 배치 파일이 실행됩니다. 배치 파일은 레지스트리 파일을 실행하고 실행 가능한 소프트웨어를 실행합니다. 내가 테스트했지만, 그 박쥐는 말을 에코 실행할 때 그것을 잘 작동합니다 ... 나는 아래의 배치와 그 배치 파일을 교체 할 때에 "Hello World!"를 :
start /d "C:\Cogent\cls.chd\" cls.reg
SLEEP 5
start /d "C:\Cogent\cls.chd\bin\" CLSMain.exe
내가 같은 평 파일을 실행 다음과 같은 오류가 발생합니다.
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"
누구나 내가 분명히 이해하지 못하는 것을 말할 수 있습니까? 내 GUI는 아래와 같습니다.
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
거의 같은 오류가 발생합니다. 나는 그것이 tkinter에만 국한된 것이라고 생각하지 않는다. 버튼이 작동하고 GUI가 좋다. 하위 프로세스 명령에 문제가있는 것 같지만 정확하게 무엇인지 알려주지는 못합니다. – Thr1llhouse
그럴 경우 GUI와 관련된 모든 것을 제거 할 수 있습니다. http://stackoverflow.com/help/mcve 및 http://ericlippert.com/2014/03/05/how-to-debug-small-programs/ – jonrsharpe