# 10.3: Interactive Parameter Control in PyCX


In Code 10.6, the parameter values are all directly given in the code and are not change able from the control window. PyCX has a feature, however,by which you can create interactive parameter setters (thanks to Przemysław Szufel and Bogumił Kami´nski at the Warsaw School of Economics who developed this nice feature!). A parameter setter should be defined as a function in the following format:

This may look a bit confusing, but all you need to do is to fill in the <...> parts. Note that the int function in the code above may need to be changed according to the type of the parameter (float for real-valued parameters, str for string-valued ones, etc.). Once you define your own parameter setter functions, you can include them as an option when you call the pycxsimulator.GUI() function as follows:

Here is an example of a parameter setter implementation that allows you to interactively change the number of particles:

Once you apply this modification to Code 10.6 and run it, the new parameter setter appears under the “Parameters” tab of the control window (Fig. 10.4.1). You can enter a new value into the input box, and then click either “Save parameters to the running model” or “Save parameters to the model and reset the model,” and the new parameter value is reﬂected in the model immediately.

##### Exercise $$\PageIndex{1}$$

To the code developed above, add one more parameter setter for sd (standard deviation of Gaussian noise for random motion of particles).

This page titled 10.3: Interactive Parameter Control in PyCX is shared under a CC BY-NC-SA 3.0 license and was authored, remixed, and/or curated by Hiroki Sayama (OpenSUNY) via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.