
Multiple Inputs in Shiny for Python || Winston Chang || RStudio
Shiny makes it easy to build interactive web applications with the power of Python’s data and scientific stack. You can try out Shiny for Python without installing a single thing… All in the browser. Learn more about Shiny for Python: https://shiny.rstudio.com/py/ Check out our interactive Shiny for Python examples: https://shinylive.io/py/examples/ Content: Winston Chang (@winston_chang)
image: thumbnail.jpg
Transcript#
This transcript was generated automatically and may contain errors.
So there's a whole bunch of different inputs and outputs. And actually, let me open this up, open up this in another tab. I'll just open up there because there are many examples for the different inputs and outputs. So here we have inputs. So what we saw before was the slider input. And if you click on this over here, you'll see a really basic example of that.
But there's also a text input. So I can enter text here, say, Hello Shiny. And this example app will show how to use that. There's a numeric input. So it's similar to the text input, but uses a number input and you can, there's little arrows on it. Checkbox input, checkbox input, which you can just turn on and off by checking it, or sorry, by clicking on it. And there's a whole bunch of other ones. So there's groups of check boxes. There's radio buttons. There's a select input that has a dropdown box and dates and date ranges. So these are the built-in inputs for Shiny.
With all these inputs, they all sort of have a common format where you say UI dot input something. And then the first thing that it's going to have here, the first argument that it takes is an ID and then a label for it. And then there's typically other parameters as well. So in this case, we're not using any of the other parameters, but so if we go to the slider input, it'll have, you have to set the minimum and maximum value for the slider, as well as like, as well as the starting value.
Adding a checkbox input to the app
One thing that you can do with these is if you have an idea of what, of the kind of components that you want to add to your application is, you know, let's say we're working on this application here and we want to add like a checkbox to it. So like if we want to be able to negate the value, so I can say, we'll put a comma there just because that will help this auto-completion. I can say UI dot input underscore checkbox, and then parens, and then I can give it a name like negate and negate slider value. I'll call it, use that as a label. And I can click on this button and it will, it will provide this checkbox, which right now doesn't do anything. We need to actually use it in our application.
So let's see. So let's say, how would we do this here? So we say, we say if input dot negate, then I'll call this multiplier equals negative one, else multiplier, multiplier equals one. All right, and then I can put this here.
And if I rerun this, then this will work here. Now I didn't actually fix the texture with this n times two, but, but you can see how this works that just simply, you know, clicking on this will cause this code to re-execute, and this, this value will be updated. And, and again, you know, if we, there's other types of inputs that we want to use, we can just refer to this examples page. Here I'm in another browser tab, and I can just look for different types of inputs to use.

