So, here's the deal. I am making a pretty simple program, but I seem to have a major problem. I have a loop in the code that is supposed to keep executing a command until the user presses a button. The problem is, I cannot figure out what I should make the command of the button in order to break out of the loop. Here is a simplified version of the code I have right now:

while(True):
     self.b = Button(self,text="Stop",command=break)
     self.b.grid()
     print "Doing something"
     time.sleep(1)

With this code, it allows the user to click the button while in the loop, and it executes the commands as it should, but when the command of the button is "break" it raises a syntax error. What should I make the command of the button be in order to break from the loop?

Thanks so much, in advance!

Just kidding, I figured it out. Thanks anyway.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.