I can't get the confirm button yes of Sytem.gui.confirm?

I want to get the confirm button YES

Can you please share your current code, or explain what you are trying to do?

1 Like

system.gui.confirm(“some message”) returns a bool per the documentation.


If the user clicks “Yes” then system.gui.confirm("some message") returns a True, or a 1.

This allows it to be used like so -

if system.gui.confirm("Are you sure you want to shutdown the plant?",
 "Really Shutdown?"):
   system.db.runUpdateQuery("UPDATE ControlTable SET Shutdown=1")

Yes, but I need to catch the event at the moment to press YES in the gui.confirm.
That is what I am trying to do.
And then change an user after press YES

It blocks the entire UI thread. What do you mean you need to catch the moment? You need the timestamp it is clicked?

Edit: Just saw your comment. I don’t see why you can’t use it the way I provided

if system.gui.confirm("Change user?"):
    # Logic to change user here


system.gui.confirm(u’Do you want to close?’, ‘Confirm’)

username = “user”

success = system.security.switchUser(username,password,event)

This works with a button but I need it in the client menu bar but needs an event ((username,password,event)) and I want to get the component of the window trying to do something like:

if system.gui.confirm = YES:
Then change the user (but I still need the event )

Use triple backticks to format your code

if something:
    #do something

it’s heard to read otherwise.

If it’s in a client menu bar then you’re taking it out of all windows and it’s not asscoiated with a window. Either put it in a window and you can look at the parent window. Or if it’s the client menu bar and you want to see what windows are opened to do some extra logic on that, you can use system.gui.getOpenedWindowNames system.gui.getOpenedWindowNames - Ignition User Manual 8.0 - Ignition Documentation

OK thanks, and with this:
success = system.security.switchUser(username,password,event)
It is the only way to switch to other user?

According to the documentation
system.security.switchUser - Ignition User Manual 8.1 - Ignition Documentation.

The third parameter -
EventObject event - If specified, the enclosing window for this event’s component will be closed in the switch user process. Refer to the list of Event objects.

So it seems like an optional argument. I don’t think you need to pass the event - only if you are doing this from within a window, and want the window to close upon a successful switching of the users.

This then - success = system.security.switchUser(username,password) should suffice.