Note that there are some explanatory texts on larger screens.

plurals
  1. POwx's idle and UI update events in PyQt
    primarykey
    data
    text
    <p>wx (and wxPython) has two events I miss in PyQt: </p> <ul> <li><code>EVT_IDLE</code> that's being sent to a frame. It can be used to update the various widgets according to the application's state</li> <li><code>EVT_UPDATE_UI</code> that's being sent to a widget when it has to be repainted and updated, so I can compute its state in the handler</li> </ul> <p>Now, PyQt doesn't seem to have these, and the PyQt book suggests writing an <code>updateUi</code> 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?</p> <hr> <p>An example: I have a simple app with a Start button that initiates some processing. The start button should be enabled only when a file has been opened using the menu. In addition, there's a permanent widget on the status bar that displays information.</p> <p>My application has states:</p> <ol> <li>Before the file is opened (in this state the status bar show something special and the start button is disabled)</li> <li>File was opened and processing wasn't started: the start button is enabled, status bar shows something else</li> <li>The processing is running: the start button now says "Stop", and the status bar reports progress</li> </ol> <p>In Wx, I'd have the update UI event of the button handle its state: the text on it, and whether it's enabled, depending on the application state. The same for the status bar (or I'd use EVT_IDLE for that).</p> <p>In Qt, I have to update the button in several methods that may affect the state, or just create a update_ui method and call it periodically in a timer. What is the more "QT"-ish way?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload