Error in ignition 7.9.21

Hello I have an error in ignition 7.9.21 that I cannot figure out. I am new to ignition. The script and error are below. The error is coming from a button press that is linked to the script. In the script tools there is no error though.

Error in first box is actionperformed but still pops up my GUI.

Traceback (most recent call last):

  File "<event:actionPerformed>", line 1, in <module>

TypeError: 'com.inductiveautomation.ignition.common.script.ScriptModule' object is not callable



Ignition v7.9.21 (b2022072613)
Java: Oracle Corporation 1.8.0_371
from javax.swing import JFrame, JTextField, JTextArea, JScrollPane, JButton, JPanel
from java.awt import BorderLayout
from java.awt.event import ActionListener, KeyAdapter, KeyEvent
from java.awt import GridLayout

def process_user_input():
    user_input = input_field.getText()
    output_area.append("User: " + user_input + "\n")
    input_field.setText("")

    response = ""
    if user_input.lower() == "hello":
        response = "Hello! How can I assist you?"
    elif user_input.lower() == "goodbye":
        response = "Goodbye! Have a great day!"
    elif user_input.lower() == "stuck in back-to-bottom?":
        display_new_question_set()
        return
    elif user_input.lower() == "pump not ramping up?":
        response = "To troubleshoot 'Pump not ramping up?', you can try the following:\n\n" \
                   "1. Check if Edge Autopilot is enabled and pumps are turned on from the Native system.\n" \
                   "2. Check if IBOP is open.\n" \
                   "3. If it still does not work, please call the hotline at (+1832-459-4507)."
    else:
        response = "I'm sorry, I didn't understand that. Can you please rephrase?"

    output_area.append("Bot: " + response + "\n")

def display_new_question_set():
    question_panel.removeAll()

    new_questions = [
        "Pump not ramping up?",
        "Rotary not ramping up?",
        "Not lowering the blocks?",
        "Auto-Zeroes not working?"
    ]

    for question in new_questions:
        question_button = JButton(question)
        question_button.addActionListener(question_button_clicked)
        question_panel.add(question_button)

    frame.revalidate()
    frame.repaint()

def question_button_clicked(event):
    question = event.getActionCommand()
    input_field.setText(question)
    process_user_input()

frame = JFrame("Chatbot")
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE)
frame.setSize(400, 300)
frame.setLayout(BorderLayout())

input_field = JTextField()
frame.add(input_field, BorderLayout.NORTH)

output_area = JTextArea()
output_area.setEditable(False)
scroll_pane = JScrollPane(output_area)
frame.add(scroll_pane, BorderLayout.CENTER)

question_panel = JPanel()
question_panel.setLayout(GridLayout(2, 2))

# Add the "Stuck in Back-to-bottom?" question as a subset question
stuck_question_button = JButton("Stuck in Back-to-bottom?")
stuck_question_button.addActionListener(lambda event: display_new_question_set())
question_panel.add(stuck_question_button)

# Add additional subset questions
subset_questions = [
    "Pump not ramping up?",
    "Rotary not ramping up?",
    "Not lowering the blocks?",
    "Auto-Zeroes not working?"
]

for question in subset_questions:
    question_button = JButton(question)
    question_button.addActionListener(question_button_clicked)
    question_panel.add(question_button)

frame.add(question_panel, BorderLayout.SOUTH)

frame.setVisible(True)```

So, someone didn't like Ignition, so re-implemented their own popup with Java Swing, instead of making an Ignition popup window. :frowning_face:

I'm afraid your error message is insufficiently detailed (did you click the button for the full message before copying?), as line #1 is an import. Or looks to be. Try to get more error details.

Do you want the full stack error, I built the entire thing. So I should build a pop up window instead inside ignition?

Yes, Vision windows can be configured to behave like popups, using all of Ignition's UI components. There's even a preset for new windows for it. So you can (mostly) ignore that it is Swing under the hood. Falling back on fully custom JFrame instances is a sign you've screwed up (with extraordinarily rare exceptions).

1 Like

Please excuse the late reply but I am trying to make it to where it has questions an gives an answer within the pop up menu after the button clicked is that possible with ignition?