I want to get the confirm button YES
Can you please share your current code, or explain what you are trying to do?
system.gui.confirm(âsome messageâ) returns a bool per the documentation.
https://docs.inductiveautomation.com/display/DOC79/system.gui.confirm
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
Code:
system.gui.confirm(uâDo you want to close?â, âConfirmâ)
username = âuserâ
password=â1234â
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.