# System.gui.inputbox has no attribute 'text'

**URL:** <https://forum.inductiveautomation.com/t/system-gui-inputbox-has-no-attribute-text/79106>\
**Category:** Ignition\
**Tags:** ignition79\
**Created:** [September 13, 2023, 6:18pm UTC](https://forum.inductiveautomation.com/t/system-gui-inputbox-has-no-attribute-text/79106 "2023-09-13T18:18:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brent\_Osterkamp1](https://avatars.discourse-cdn.com/v4/letter/b/ebca7d/32.png) [@Brent\_Osterkamp1](https://forum.inductiveautomation.com/u/Brent_Osterkamp1)\
**Post date:** [September 13, 2023, 6:18pm UTC](https://forum.inductiveautomation.com/t/system-gui-inputbox-has-no-attribute-text/79106/1 "2023-09-13T18:18:44Z")

</div>

I am running 7.9.18 and have a button that I want to run a system.gui.inputbox in the script.

When I try I get the following error

```auto
Traceback (most recent call last):
  File "<event:mousePressed>", line 3, in <module>
AttributeError: 'com.inductiveautomation.factorypmi.application.com' object has no attribute 'text'

	at org.python.core.Py.AttributeError(Py.java:173)
	at org.python.core.PyObject.noAttributeError(PyObject.java:930)
	at org.python.core.PyObject.object ___getattribute__ (PyObject.java:3692)
	at org.python.core.PyObject$object ___getattribute___ exposer. __call__ (Unknown Source)
	at org.python.core.Deriveds. __findattr_ex__ (Deriveds.java:59)
	at org.python.core.PyObjectDerived. __findattr_ex__ (PyObjectDerived.java:983)
	at com.inductiveautomation.factorypmi.application.script.PyComponentWrapper. __findattr_ex__ (PyComponentWrapper.java:131)
	at org.python.core.PyObject. __getattr__ (PyObject.java:923)
	at org.python.pycode._pyx80.f$0(<event:mousePressed>:5)
	at org.python.pycode._pyx80.call_function(<event:mousePressed>)
	at org.python.core.PyTableCode.call(PyTableCode.java:165)
	at org.python.core.PyCode.call(PyCode.java:18)
	at org.python.core.Py.runCode(Py.java:1275)
	at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:636)
	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:193)
	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.invoke(ActionAdapter.java:284)
	at com.inductiveautomation.factorypmi.application.binding.action.RelayInvocationHandler.invoke(RelayInvocationHandler.java:57)
	at com.sun.proxy.$Proxy41.mousePressed(Unknown Source)
	at java.desktop/java.awt.Component.processMouseEvent(Unknown Source)
	at java.desktop/javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.desktop/java.awt.Component.processEvent(Unknown Source)
	at java.desktop/java.awt.Container.processEvent(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.EventQueue.access$500(Unknown Source)
	at java.desktop/java.awt.EventQueue$3.run(Unknown Source)
	at java.desktop/java.awt.EventQueue$3.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
	at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)

Ignition v7.9.18 (b2021062913)
Java: Azul Systems, Inc. 9.0.7.4

```

I am just trying right now with the off the shelf script from the help document

```auto
txt = system.gui.inputBox("Enter text:", event.source.text)
if txt != None:
   event.source.text = txt

```

---

<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:** [September 13, 2023, 6:27pm UTC](https://forum.inductiveautomation.com/t/system-gui-inputbox-has-no-attribute-text/79106/2 "2023-09-13T18:27:56Z")

</div>

Try without the broken punctuation.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [September 13, 2023, 6:28pm UTC](https://forum.inductiveautomation.com/t/system-gui-inputbox-has-no-attribute-text/79106/3 "2023-09-13T18:28:03Z")

</div>

If you check the doc that second argument is just the default text -  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/d/0dd6a280978b646261241eee636c4fe412836a27.png)

I don't know where you are putting your script, but wherever it is, does not have a .text property. Just put your default text value directly in it.

Also to format code on the forum do it like so

```

```auto
txt = system.gui.inputBox("Enter text:", event.source.text)
if txt !=None:
    event.source.text =txt

```

```

Three ticks to start, your code, then three ticks to finish.

---

<div class="post-metadata">

**Author:** ![Brent\_Osterkamp1](https://avatars.discourse-cdn.com/v4/letter/b/ebca7d/32.png) [@Brent\_Osterkamp1](https://forum.inductiveautomation.com/u/Brent_Osterkamp1)\
**Post date:** [September 13, 2023, 6:36pm UTC](https://forum.inductiveautomation.com/t/system-gui-inputbox-has-no-attribute-text/79106/4 "2023-09-13T18:36:35Z")

</div>

My thought on using this is as follows.

1. on a button push call the gui.inputbox to enter/scan a badge number
2. use the input from the input to check in a database if the badge has the appropriate user level
3. if they do open the appropriate screen if not error box.

```auto
temp = system.gui.inputBox("Enter text:", event.source.text)

if len(temp) == 5:
	id = temp
	qu = "select role_id from [IgnitionDB].[dbo].[BadgeScan_user_rl] rid "
	qu += "INNER JOIN [IgnitionDB].[dbo].[BadgeScan_users] bs_user on rid.user_id = bs_user.id "
	qu += "where bs_user.username = 'u%s'"%id
	try:
	    rst = system.db.runScalarQuery(qu,"IgnitionDB")
	except:
	    err += "%s\n"%traceback.format_exc()
	    
if rst >= 4:
	window = system.nav.openWindow('Adjust offset')
	system.nav.centerWindow(window)
else:
	errorMessage = "Maintenance user rights required."
	errorMessage += " You don't have proper security privileges."
	system.gui.errorBox(errorMessage)

```

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [September 13, 2023, 6:51pm UTC](https://forum.inductiveautomation.com/t/system-gui-inputbox-has-no-attribute-text/79106/5 "2023-09-13T18:51:47Z")

</div>

Couple of things. the text property of a button is simply what you see on the button label, so I suggest you just change that line to  
`system.gui.inputBox("Enter text:", 'SOME HARDCODED DEFAULT HERE')` or do an empty string if you don't want anything like `''`.

Instead of getting your roles by querying the tables directly, use `system.security.getRoles` [system.security.getRoles - Ignition User Manual 7.9 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC79/system.security.getRoles) - let the user source manage this for you and use the system.user api to get what you need. With this too, you don't need to enter anything presuming that a user is already logged in. However, if a user is not logged in you can do that too.

Assuming a user is not logged in and you are okay with logging them in here -

```auto
user = system.gui.inputBox("Username", "")
password = system.gui.passwordBox("Password", "")
# the next line will try to log the user in, returns True if user/pass worked false otehrwise
loggedIn = system.security.switchUser(user, password)
if loggedIn:
    roles = system.security.getRoles()
    # Now you can use the actual names of the roles instead of having to rely on the id
    if 'someRole' in roles:
        window = system.nav.openWindow('Adjust offset')
    	system.nav.centerWindow(window)
    else:
        errorMessage = "Maintenance user rights required. You don't have proper security privileges."
	    system.gui.errorBox(errorMessage)

```

This is how I would do it. With Ignition, if there's any part that you have to configure in the gateway like a user source, odds are there is an API they provide for you to use so you don't have to run raw sql regarding it.

The way you're doing it the person only needs to know a username to get access which is not very secure.
