Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default values for inputs #36

Open
natalia-wz opened this issue Nov 5, 2019 · 3 comments
Open

Default values for inputs #36

natalia-wz opened this issue Nov 5, 2019 · 3 comments

Comments

@natalia-wz
Copy link

What a great plugin!
I was wondering though if there is a way of setting the default values for the inputs?
Many thanks,
N/

@MahmoudAbdelRahman
Copy link
Owner

Hi @buka71,
You can set them inside the python code, once you initiate the component, you might need to delete the default input _input and add other inputs e.g. x, y, width, ... .

@natalia-wz
Copy link
Author

Hi yes, but if I set their initial values of the inputs with the body, the input from the components that attach to them gets overwritten. If I have _x as a variable within the list of my inputs and I set _x = 5, the value that gets connected to the _x gets overwritten (If I don't, the input behaves as expected, i.e. inherits whatever I connect to it). I was wondering if there is a way of setting an initial value for _x which gets used in case nothing gets connected to that node, but gets overwritten by whatever then connects to _x.

@mrtnbrst
Copy link
Contributor

mrtnbrst commented Sep 2, 2020

Empty inputs are set to None, so for an optional parameter x with a default value of 5 you could write something like:

if x is None:
    x = 5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants