在程序中停止或取消排队的键盘命令

时间:2015-09-07 10:43:02

标签: python-2.7 command disabled-input

我有一个用python 2.7编写的程序,当结果值输入程序时,它会从3个不同的摄像机拍摄样本。

USB控制器带宽无法同时处理所有相机,因此我必须单独调用每个相机。这导致按下值和显示的图片的预览之间的延迟。

在此延迟期间,程序仍然可以接受键盘命令,然后在拍摄照片后对其进行寻址。这会引起问题,因为有时候,值会被输入两次,这意味着在为第一个样本拍摄照片后,该值会应用到下一个值。

当程序正在处理当前命令时,我所追求的是忽略任何排队键盘命令的方法

def selChange(self):
    #Disable the textbox
    self.valInput.configure(state='disabled')

    #Gather pictures from cameras and store them in 2D list with sample result (This  takes a second or two to complete)
    self.gatherPictures()

    if not int(self.SampleList.size()) == 0:
        #clear texbox
        self.valInput.delete(0,END)

        #Create previews from 2D list
        self.img1 = ImageTk.PhotoImage(self.dataList[int(self.SampleList.curselection()[0])][2].resize((250,250),Image.ANTIALIAS))
        self.pic1.configure(image = self.img1)
        self.img2 = ImageTk.PhotoImage(self.dataList[int(self.SampleList.curselection()[0])][3].resize((250,250),Image.ANTIALIAS))
        self.pic2.configure(image = self.img2)
        self.img3 = ImageTk.PhotoImage(self.dataList[int(self.SampleList.curselection()[0])][4].resize((250,250),Image.ANTIALIAS))
        self.pic3.configure(image = self.img3)
        self.img4 = ImageTk.PhotoImage(Image.open("Data/" + str(self.dataList[int(self.SampleList.curselection()[0])][1]) + ".jpg").resize((250,250),Image.ANTIALIAS))
        self.pic4.configure(image = self.img4)

    #Unlock textbox ready for next sample
    self.valInput.configure(state='normal')

我希望禁用文本框并在之后重新启用它会起作用,但事实并非如此。我想使用按钮,但他们坚持要输入以提高速度

0 个答案:

没有答案