Lpaulson
Lpaulson

Reputation: 219

Wait for button click

I'm trying to create a GUI that will have some preset test to run. Depending on what the user's selection is a secession of test will run. I'm trying to figure out what is the best way to run a test in a thread and then wait until the user presses the next button to continue.

The current way the program knows what test to run is by create a dictionary like so

A = {0:[0,0,0],1:[1,0,1],2:[0,1,1]}

the key would represent the index of a combo box and the list represent whether the test runs or not, so 0 mean don't run that particular test and 1 mean do. So, I would have a for loop that would run through the list and if it's 0 it goes to the next list element, and if it's 1 it configures the test runs it and then I would like it to wait until the user presses the next button in the GUI.

EDIT: Instead I implemented a state machine method, using Qtimer. So the GUI will stay in the wait state until the GUI send sends a signal to move from the wait sate to the next state after a button has been pressed

Upvotes: 1

Views: 1206

Answers (1)

Aleksandar
Aleksandar

Reputation: 3661

You can do it simple like this: first, disable next button in your GUI using yourNextButton.setDisabled(1); second, enable it at the end of your test yourNextButton.setDisabled(0) (I assume it is one method); with the button enabled,which means your test is done, you can click it and connect it with next operation you need to be done (next test or whatever), but do not forget to disable it again when it's clicked. If you need different behavior feel free to ask.

Upvotes: 1

Related Questions