我无法从“条目”中检索变量,然后将变量输入到函数中。例如,我想检索作为变量“条目”的“NbF”。我在“set”中做了,我可以用“get”检索它,但是当我得到一个新的文本“entry”时,我没有得到新的值。
这是我的代码:
#!/usr/local/bin/python
# -*- coding:utf-8 -*-
from Tkinter import *
import tkFileDialog, tkMessageBox
application = Tk()
application.title("Application Drone - Analyse Vidéo")
def getFile():
varName = tkFileDialog.askopenfilename().encode('utf-8')
Name.set('Path : ' + varName)
def convert(nbFrame):
print 'ffmpeg -i pathVideo -r '+nbFrame+' -f image2 "temp%4d.png"'
def detect():
pass
def analyse():
pass
frame1 = Frame(application, bg="blue", width=560, height=100)
frame1.pack(side=TOP, fill=X)
frame2 = Frame(application, bg="red", width=560, height=100)
frame2.pack(side=TOP, fill=X)
frame3 = Frame(application, bg="green", width=560, height=100)
frame3.pack(side=TOP, fill=X)
frame4 = Frame(application, bg="yellow", width=560, height=100)
frame4.pack(side=TOP, fill=X)
frame5 = Frame(application, bg="grey", width=560, height=100)
frame5.pack(side=BOTTOM, fill=BOTH, expand=1)
#frame 1
Name=StringVar()
lab1 = Label(frame1, text="Step 1 : Recup video").grid(row=0,column=0)
butt1 = Button(frame1,text="browse",command=getFile).grid(row=0,column=1)
nameVideo = Label(frame1, textvariable=Name).grid(row=1,column=0)
#frame 2
NbF = StringVar()
NbPictures=StringVar()
lab2 = Label(frame2, text="Step 2 : Convert video to images").grid(row=0,column=0)
ent2 = Entry(frame2, textvariable=NbF).grid(row=0,column=1)
# ent2.pack()
NbF.set('nb frame')
recup2 = NbF.get()
butt2 = Button(frame2,text="convert",command=lambda :convert(recup2)).grid(row=0,column=2)
nbP = Label(frame2, textvariable=NbPictures).grid(row=1,column=0)
#frame 3
NbS=StringVar()
lab3 = Label(frame3, text="Step 3 : Detect shape").grid(row=0,column=0)
butt3 = Button(frame3,text="detect",command=lambda :detect).grid(row=0,column=1)
numberShape = Label(frame3, textvariable=NbS).grid(row=1,column=0)
#frame 4
NbC=StringVar()
lab4 = Label(frame4, text="Step 4 : Analyse QrCode").grid(row=0,column=0)
butt4 = Button(frame4,text="analyse",command=lambda :analyse).grid(row=0,column=1)
numberCoord = Label(frame4, textvariable=NbC).grid(row=1,column=0)
#frame 5
lab5 = Label(frame5, text="Step 5 : Send coordonates").grid(row=0,column=0)
butt5 = Button(frame5,text="send",command=lambda :send).grid(row=0,column=1)
application.mainloop()