I was using sleep to emulate a brief amount of time the computer was waiting for something to happen As I stated in my question, I didn't want to use events because it's a whole lot of unnecessary work to accomplish something extremely simply Also, the 'event' that needs to take place for the program to continue, is a USB event. Since I'm using an HID class device, there is no way to set an event to happen without a wait loop. USB HID classes don't permit setting interrupts, the OS claims the device I managed to get the above to work.
I walked through the debugger and noticed the display would refresh before the sleep function. Running the program independently, I got random results with the display refreshing 1% of the time. I got rid of the sleep function, and added some other code in it's place to emulate a delay, and it was fine Just for everyone's knowledge, this is possible, it's not forbidden, and it's easy to do with the following: qApp->processEvents() qApp is a global external variable in the QApplication header Because this USB event is making my flow tricky, I stumbled upon the QWaitCondition Class.
I was going to start a process waiting for the USB event. I would wait until the process releases the wait condition for my routine to continue But if anyone thinks this is a bad idea, please, speak out. I really do appreciate your feedback PiedPiper and Hostile Fork Thank you.
I was using sleep to emulate a brief amount of time the computer was waiting for something to happen. As I stated in my question, I didn't want to use events because it's a whole lot of unnecessary work to accomplish something extremely simply. Also, the 'event' that needs to take place for the program to continue, is a USB event.
Since I'm using an HID class device, there is no way to set an event to happen without a wait loop. USB HID classes don't permit setting interrupts, the OS claims the device. I managed to get the above to work.
I walked through the debugger and noticed the display would refresh before the sleep function. Running the program independently, I got random results with the display refreshing 1% of the time. I got rid of the sleep function, and added some other code in it's place to emulate a delay, and it was fine.
Just for everyone's knowledge, this is possible, it's not forbidden, and it's easy to do with the following: qApp->processEvents(); qApp is a global external variable in the QApplication header. Because this USB event is making my flow tricky, I stumbled upon the QWaitCondition Class. I was going to start a process waiting for the USB event.
I would wait until the process releases the wait condition for my routine to continue. But if anyone thinks this is a bad idea, please, speak out. I really do appreciate your feedback PiedPiper and Hostile Fork.
Thank you.
You shouldn't be waiting for input in your event handler. You need to rethink the logic of your program to use events the way they were intended. All the update() and repaint() calls in your code are unnecessary if you return to the event loop.
If I understood correctly, you have a slot and in this slot, you update the image shown in a QLabel. But you want this change to be displayed before the slot finishes. If that is the case, issue an update() event, and call qApp->processEvents().
This method processes events that are waiting in the event queue and then returns, therefore this may be what you are after. PS: an update() may not be necessary at all, I am not sure.
Now, PyQt doesn't seem to have these, and the PyQt book suggests writing an updateUi method and calling it manually. I even ended up calling it from a timer once per 0.1 seconds, in order to avoid many manual calls from methods that may update the GUI. Am I missing something?
Is there a better way to achieve this?
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.