bugpyFormex - Bugs: bug #43024, warning() + interact with GUI


bug #43024: warning() + interact with GUI

Submitter:  gianluca de santis <gianlucadesi>
Submitted:  Tue 19 Aug 2014 02:07:01 PM UTC
Category:  GUI Severity:  1 - Wish
Item Group:  Feature request Status:  Confirmed
Privacy:  Public Assigned to:  None
Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup

Mon 23 May 2016 05:37:33 PM UTC, comment #5: 

Adding a more general action list, as suggested in previous remark, seems to become tedious and unwanted. The QMessageBox dialog used in showInfo and related, is a specialized (Qt) dialog that has other goals than the general pyFormex InputDialog, which implements an action list. Implementing out action list in the MessageBox would duplicate a lot of functionality.

It is better to work the other way around and use our standard InputDialog. You can get the wanted functionality as follows:

def cont():
    """Continue a paused script"""
    if len(pf.scriptlock) > 0:

def close_cont():
    """Close the dialog dia and continue a paused script and"""
    global dia

txt = "Hallo, here I am.\nDo you like me?"
actions = [('Close and continue',close_cont),('Next',cont)]

dia = Dialog([_I('msg',txt,itemtype='label',text=None)],
pause(msg="I am pausing now")
print("Executing remainder of the script")

Compared with the MessageBox, we only miss the default icons for info, warning, error, ... Maybe we can add such functionality in general to our Dialog label items?

Benedict Verhegghe <bverheg>
Group administrator
Mon 23 May 2016 12:35:29 PM UTC, comment #4: 

A script is executed in a single stream and can be paused properly by
- a modal dialog
- a pause() command.
You could find other tricks to pause, but they will likely end up in using 100% CPU time and/or GUI events not being processed properly.

A modal dialog does not let you use other GUI components while it is open: you have to acknowledge it first.
If you want to pause with a non-modal dialog (modal=False), you have to add the pause command explicitely to stop the script processing. The following would work:

showInfo("Hallo, here I am",actions=['Close'],modal=False)
pause(msg="I am pausing now")
print("Executing remainder of the script")

However, you are required now to press twice to close the dialog AND continue the script: the 'Close' dialog button to close the dialog and the PLAY toolbar button to continue the script.

Can you do both with a single click? Currently not with showInfo, because the actions list does not allow to specify a function (the associated function is always just closing the dialog).
But you can use the showText function instead: this accepts a list of actions bound to user functions.

dia = showText("Hallo, here I am",actions=[('Continue',play)],modal=False)
pause(msg="I am pausing now")
print("Executing remainder of the script")

In this case the play function is bound to the dialog's 'Continue' button. Thus the script will continue when clicked. The dialog has still to be closed then. And you could of course create a function that executes play and closes the dialog.

A backdraw of this second method is that the showText was intended for large texts, and may not display a short message as nice as showInfo. But you could add a s resize to fix that.

Conclusion: there is enough available to do what you want, but maybe we should enhance the showInfo and related function to allow an action list that binds to specified functions. That would also simplify thinks in that the actions parameter would have same meaning and value in all functions.
Therefore, I removed the 'wont fix' status.

Benedict Verhegghe <bverheg>
Group administrator
Mon 23 May 2016 11:04:01 AM UTC, comment #3: 

I reopen this for a small need.

When displaying a warning/message I would like to:
- use the interface (e.g. rotate)
- do not execute the part of the scripts below the warning before acknowledging the message

If I am correct, if modal=False, you can use the interface but the script proceeds until the end.

gianluca de santis <gianlucadesi>
Group Member
Mon 23 May 2016 07:38:41 AM UTC, comment #2: 

Closed, as I suppose there is no need for this. Reopen if there is still a need.

Benedict Verhegghe <bverheg>
Group administrator
Wed 20 Aug 2014 10:35:36 AM UTC, comment #1: 

In gui.draw, showInfo, warning and error are defined as wrappers around showMessage, which has a `modal` parameter. Setting this to False will let you proceed with the interface before acknowledging the message.

While showInfo exposes the `modal` parameter, warning and error do not, but always force modal=True. This is because warning and error are considered to report exceptional behavior, which should not go unnoticed. Otherwise, if a user reacts fast, he might do the next thing before he has even seen the message.

We could expose the modal parameter in warning to allow nonblocking warnings, but perhaps it is better to just use showInfo in such cases, or if you want to have the message displayed as a warning, use showMessage(level='warning').

Benedict Verhegghe <bverheg>
Group administrator
Tue 19 Aug 2014 02:07:01 PM UTC, original submission:  

Would it be possible to rotate/zoom when a warning is raised before clicking on Ok?
Also, would it be possible to rotate/zoom when a dialog is open until you click on Close?
Of course, you could put all the rest of the code inside the Close function, but is there a way to leave it out?

gianluca de santis <gianlucadesi>
Group Member


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by bverheg (Posted a comment)
  • -email is unavailable- added by gianlucadesi (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.


    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-05-23 bverheg StatusWont Fix Confirmed
    2016-05-23 gianlucadesi Open/ClosedClosed Open
    2016-05-23 bverheg StatusNone Wont Fix
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-04b1.
    Corresponding source code