# System.gui.messageBox and System.gui.confirm issue

**URL:** <https://forum.inductiveautomation.com/t/system-gui-messagebox-and-system-gui-confirm-issue/18269>\
**Category:** Ignition\
**Created:** [June 2, 2018, 9:59pm UTC](https://forum.inductiveautomation.com/t/system-gui-messagebox-and-system-gui-confirm-issue/18269 "2018-06-02T21:59:36Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![jshaffer09](https://avatars.discourse-cdn.com/v4/letter/j/df788c/32.png) [@jshaffer09](https://forum.inductiveautomation.com/u/jshaffer09)\
**Post date:** [June 2, 2018, 9:59pm UTC](https://forum.inductiveautomation.com/t/system-gui-messagebox-and-system-gui-confirm-issue/18269/1 "2018-06-02T21:59:36Z")

</div>

When I added System.gui.messageBox to my code it continues to pop up even if you try to close it out. Like it is in a loop. Also wondring how to get the confirmation from System.gui.Confirm to complete the code.

---

<div class="post-metadata">

**Author:** ![jshaffer09](https://avatars.discourse-cdn.com/v4/letter/j/df788c/32.png) [@jshaffer09](https://forum.inductiveautomation.com/u/jshaffer09)\
**Post date:** [June 2, 2018, 10:01pm UTC](https://forum.inductiveautomation.com/t/system-gui-messagebox-and-system-gui-confirm-issue/18269/2 "2018-06-02T22:01:49Z")

</div>

this is what I have. I have both commented out right now.

```auto
#get data from dataset
data = event.source.parent.getComponent('Power Table').data

for row in range(data.getRowCount()):
	# Loops though each row and if at least one of the column contains a blank cell, the row will be skipped.
	skipRowFlag = 0
	for col in range(data.getColumnCount()):
		if data.getValueAt(row, col) == "":
			skipRowFlag = 1
			break
	# Insert the row into the database if the every column in that row was good
	#system.gui.confirm("Are you sure?")
	if not skipRowFlag:
		query = "INSERT INTO IngStackAnalysis(StackNbr,ProblemArea, Occurrence, PercentOfTotal, DateTm) VALUES(1,?,?,?,?)"
		args = [data.getValueAt(row, 0), data.getValueAt(row, 1), data.getValueAt(row, 2), system.date.now()]
		system.db.runPrepUpdate(query, args)
    	#system.gui.messageBox("Data Inserted")

```

event is a mouse click

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [June 2, 2018, 10:16pm UTC](https://forum.inductiveautomation.com/t/system-gui-messagebox-and-system-gui-confirm-issue/18269/3 "2018-06-02T22:16:40Z")

</div>

Your code is completely unreadable. Please add triple-back-quotes on lines by themselves before and after the code so it’ll format neatly. Just edit in place – don’t re-post.

Also, what event is this code activated by?

---

<div class="post-metadata">

**Author:** ![jshaffer09](https://avatars.discourse-cdn.com/v4/letter/j/df788c/32.png) [@jshaffer09](https://forum.inductiveautomation.com/u/jshaffer09)\
**Post date:** [June 2, 2018, 10:39pm UTC](https://forum.inductiveautomation.com/t/system-gui-messagebox-and-system-gui-confirm-issue/18269/4 "2018-06-02T22:39:12Z")

</div>

I tried the quotes, not sure if that worked.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [June 3, 2018, 12:26am UTC](https://forum.inductiveautomation.com/t/system-gui-messagebox-and-system-gui-confirm-issue/18269/5 "2018-06-03T00:26:45Z")

</div>

No, you need three of the single reverse quotes, twice, above and below the code block. On US keyboards, to the left of the ‘1’.

See this documentation:

> **[Syntax highlighting of code blocks](https://meta.discourse.org/t/syntax-highlighting-of-code-blocks/7242)**
>
> We have a pretty technical forum with frequent code blocks. We need some color in our lives! highlight.js is pretty awesome for this. Here’s an example of highlight.js in action:

---

<div class="post-metadata">

**Author:** ![jshaffer09](https://avatars.discourse-cdn.com/v4/letter/j/df788c/32.png) [@jshaffer09](https://forum.inductiveautomation.com/u/jshaffer09)\
**Post date:** [June 3, 2018, 11:28am UTC](https://forum.inductiveautomation.com/t/system-gui-messagebox-and-system-gui-confirm-issue/18269/6 "2018-06-03T11:28:39Z")

</div>

I got it where it is readable now

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [June 3, 2018, 12:15pm UTC](https://forum.inductiveautomation.com/t/system-gui-messagebox-and-system-gui-confirm-issue/18269/7 "2018-06-03T12:15:32Z")

</div>

How many times do your message boxes pop up? It looks from your code that it would be one of each for each row in your table. Try placing them inside the inner `if` block.

Or consider simply disabling the button until the operator does something in the UI to confirm (clicks a first button), avoiding the need for the “Are you sure?” prompt entirely. Then your code doesn’t need to worry about jumpy operators.

---

<div class="post-metadata">

**Author:** ![jshaffer09](https://avatars.discourse-cdn.com/v4/letter/j/df788c/32.png) [@jshaffer09](https://forum.inductiveautomation.com/u/jshaffer09)\
**Post date:** [June 3, 2018, 12:23pm UTC](https://forum.inductiveautomation.com/t/system-gui-messagebox-and-system-gui-confirm-issue/18269/8 "2018-06-03T12:23:46Z")

</div>

24 times after adding it to the inner if. If I do the extra button, then how do I get the message box for insert to happen once since the code loops through the rolls which I need it to do.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [June 3, 2018, 1:21pm UTC](https://forum.inductiveautomation.com/t/system-gui-messagebox-and-system-gui-confirm-issue/18269/9 "2018-06-03T13:21:04Z")

</div>

Keep that message box in your code, then. Just don’t indent it so it’s not part of the loop. Set a counter variable to zero at the beginning of the script and increment it inside the inner if block. Then your message can display how many rows were processed.

It seems you are struggling with basic python structure. Consider going through the [python tutorial](https://docs.python.org/2/tutorial/index.html). Just note that the linked tutorial is for python 2.7 where Ignition’s jython is (currently) v2.5.

---

<div class="post-metadata">

**Author:** ![jshaffer09](https://avatars.discourse-cdn.com/v4/letter/j/df788c/32.png) [@jshaffer09](https://forum.inductiveautomation.com/u/jshaffer09)\
**Post date:** [June 3, 2018, 2:23pm UTC](https://forum.inductiveautomation.com/t/system-gui-messagebox-and-system-gui-confirm-issue/18269/10 "2018-06-03T14:23:55Z")

</div>

yes, I am new to Python scripting. I wiill read through this tutorial to see if that gets me a better understanding of it. I can’t seem to get the gui boxs to work so I went at it a different way. I can start a new topic if needed. I added a button before the submit button, when pushed it inserts the data and makes a Label popup based of a tag status = to 1. How do you delay the tag write to 0 say after 5 seconds?

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [June 3, 2018, 4:59pm UTC](https://forum.inductiveautomation.com/t/system-gui-messagebox-and-system-gui-confirm-issue/18269/11 "2018-06-03T16:59:59Z")

</div>

See examples here for system.gui.confirm (it needs to be placed as the condition in an if statement):  
[https://docs.inductiveautomation.com/display/DOC79/system.gui.confirm](https://docs.inductiveautomation.com/display/DOC79/system.gui.confirm)

system.util.invokeLater allows running a defined function (see example in link below) after a specified delay:  
[https://docs.inductiveautomation.com/display/DOC79/system.util.invokeLater](https://docs.inductiveautomation.com/display/DOC79/system.util.invokeLater)
