Python跳过迭代

时间:2019-03-03 22:36:40

标签: python skip continue

我正在使用Tkinter python 2.6 UI,并且尝试尝试使用按钮跳过命令列表中的elememt(如果特定命令花费的时间太长)。本质上,我试图从另一个函数执行“ continue”语句。请考虑以下内容:

def executeCommands(commands):
    for cmd in commands:
        sendCommand(cmd)


#arbitrary button class used as an example  
class Button(self)

    #this button executes onSkip() method when clicked
    self.skipBtn = Button('skip', command=self.onSkip)

    def onSkip(self):
        #skip to next iteration of loop that was being iterated prior to skip button execution

当执行Button类中的onSkip方法时,如何获取executeCommands方法来停止其工作并跳至下一个cmd?

0 个答案:

没有答案