0
이 코드와 PNG 파일에서 2D 코드를 읽을 libdmtx을 사용하고
에서 2D 코드, 부적절한 출력을 읽기 :파이썬 - Tkinter를
#!/usr/bin/python
import os
import Tkinter
from Tkinter import *
from tkFileDialog import askopenfilename
top = Tkinter.Tk()
top.geometry("200x200")
content = StringVar()
label = Message(top, textvariable=content, width='180')
content.set ("Choose file to read 2D code")
label.pack()
def selector():
filename = askopenfilename()
cmd = "dmtxread -n %s" % (filename)
res = Text(top)
res.insert (INSERT, os.system(cmd))
res.pack()
B = Tkinter.Button(top, text ="Choode file", command = selector)
B.pack()
top.mainloop()
모든 것이 잘 작동하지만, GUI에 나는 전체를 얻을 수 없다 산출. 0은 있지만 콘솔에서는 2D 코드를 얻습니다. GUI로 전체 출력을 얻으려면 어떻게해야합니까? os.system
당신이 실행 한 명령의 stdout
를 반환하지 않기 때문이다
가 영업 이익도 http://docs.python.org/2/library/subprocess.html ([subprocess.check_output] 고려해 볼 수 있습니다 # subprocess.check_output) 이것은 더 간단하게 만든다 –
나는 그것도 고려하고 싶어 할지도 모른다 :) 팁에 감사드립니다! –