Can't access static_text type from Model subclass?

Skip to first unread message

Stephen Davies

Feb 17, 2021, 9:57:24 AMFeb 17
to ProjectMesa
Hello, I'm trying to wire together a simple way to display status updates (in a text box) for the user to give them feedback about long-running simulations.

I thought I could do this using the "static_text" option of UserSettableParameter. But it appears that when I create such a text box, I am prohibited for some reason from passing it as an argument to the model constructor (so that the model could update the text while it's running.)

Minimum (non-)working example:

from mesa import Agent, Model
from mesa.visualization.UserParam import UserSettableParameter
from mesa.visualization.ModularVisualization import ModularServer

class MyModel(Model):
    def __init__(self, in1, msg):
    def step(self):
    def run(self):

if __name__ == "__main__":
    in1 = UserSettableParameter("slider","Input",10,1,100,1)
    msg = UserSettableParameter("static_text", value="<p>Boo</p>")
    server = ModularServer(MyModel, [], "Broken", { "in1":in1, "msg":msg })
    server.port = 8081

If "msg" is set to any other kind of UserSettableParameter (another slider, for example) this runs without error. As is, I get:

TypeError: __init__() missing 1 required positional argument: 'msg'

Lil help?

Majd Al-shihabi

Feb 17, 2021, 11:01:27 AMFeb 17
to Stephen Davies, ProjectMesa
Hi Stephen - I suggest that instead of a user-settable parameter, you use a TextElement, or TextData visualization classes. They're more adapted to what you're trying to do, as far as I can tell. Here's an example of how it can be used.

Good luck!


Project repos:
You received this message because you are subscribed to the Google Groups "ProjectMesa" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

Stephen Davies

Feb 17, 2021, 7:47:03 PMFeb 17
to ProjectMesa
Ah...thanks! I misread the documentation -- I thought those classes were only for ASCII visualizations, not graphical ones.

Works perfect -- thanks much!
Reply all
Reply to author
0 new messages