How I build Streamlit Components (a small Javascript / React tutorial)

Поділитися
Вставка
  • Опубліковано 6 жов 2024

КОМЕНТАРІ • 69

  • @ratchetrod
    @ratchetrod Рік тому +5

    I recently found out about Streamlit and decided to do some research. I felt discouraged because I read some forums that said Streamlit is limited in its customizability. You single-handedly debunked those atteststions 🙌🏾
    Thank you for the informational video, Fanilo!

    • @andfanilo
      @andfanilo  Рік тому +1

      Thank you for the kind words :) it means a lot!
      I hope my videos will keep inspiring you to push through the limits of Python webapp libraries and go past what everyone is writing on the Internet :D

  • @CodingIsFun
    @CodingIsFun 2 роки тому

    *Awesome video!* 💪 Thanks for sharing. Guess I need to learn some JS/TS now.
    npm star this video

    • @andfanilo
      @andfanilo  2 роки тому +1

      I'll never thank you enough for your support 😀eagerly waiting for your first JS component!

  • @oscargalvez7
    @oscargalvez7 Рік тому

    Wooow, I'm very impressed by the amount of work you put into this tutorial. While watching I didn't stop thinking how much time and effort you put into it. I have my own channel myself (different topic) so I know how much it takes to edit a video. And I really liked the sense of humour, I think it's something very few people dare to do and don't even talk about taking out the bongos, LOL. Great work, oh yes, and great useful information, as wel!!! 👏👏

    • @andfanilo
      @andfanilo  Рік тому

      Thank you very much for the feedback, I'm very grateful :) wishing you all the best for doing Javascript in Streamlit and in your YT channel!

  • @PrarthitShah-r6c
    @PrarthitShah-r6c Місяць тому

    Awsome video @andfanilo
    you explained the hardest concept very easily this is very very very useful
    please post more videos like this on regular basis

    • @andfanilo
      @andfanilo  Місяць тому

      Thanks for the support, see you on the next video !

  • @nlight8769
    @nlight8769 Рік тому

    Ouch, my head hurts... this is dense, and fast packed. Got to write it down, but thanks, that's super valuable information 👍👍

    • @andfanilo
      @andfanilo  Рік тому +2

      🙂 yeah I realize now that some people want a very long version...I'll try a very slow 2h version one day (that's what I should sell as a digital product ahah), but in the meantime most of the info is in streamlit-components-tutorial.netlify.app/ !

    • @nlight8769
      @nlight8769 Рік тому

      @@andfanilo Nice ! Thanks 😊

    • @darkcss1054
      @darkcss1054 Рік тому

      @@andfanilo the sidebar on that app looks awesome! I would love a tutorial teaching us how to make it 🙂

  • @cyberhard
    @cyberhard 2 роки тому

    Great video! Packed a lot of info in under 20 minutes.

    • @andfanilo
      @andfanilo  2 роки тому

      Thanks for the support! Yeah I realized after watching the video again that it may be too much for a single 20mn video 😆

  • @mohammedalbatati5529
    @mohammedalbatati5529 2 роки тому

    Just knew your channel
    I loved your work 👍👍👍
    You provide great content

    • @andfanilo
      @andfanilo  2 роки тому

      Thanks for the support 😃 Hope to see you around! Any Streamlit thing you want to see?
      Have a nice day!

  • @rockNbrain
    @rockNbrain 2 роки тому +2

    nice content and nice editing bro, loving your videos , greetings from Brazil!!

    • @andfanilo
      @andfanilo  2 роки тому +1

      Thank you for the feedback 😊 it means a lot!
      Have you tried building a component? How was the experience?

  • @timetocode_with_ali
    @timetocode_with_ali 2 роки тому +1

    wow, Python and React coming together. I love it 💜

    • @andfanilo
      @andfanilo  2 роки тому

      😃 Come build Streamlit Components in React with us, it's fun!

  • @plouf1969
    @plouf1969 Рік тому

    Awesome video. Thank you so much for doing this!

    • @andfanilo
      @andfanilo  Рік тому

      My pleasure :) thanks for the coffee, it will keep me awake to build the next one!

  •  2 роки тому

    Wonderful. Again.
    Thank you

    • @andfanilo
      @andfanilo  2 роки тому

      Thanks for the support, looking forward to your next component 😁

  • @flight5056
    @flight5056 2 роки тому

    🤯 Nice one!! .. It would be fun to create a GLTF loader for streamlit, and use sliders to experiment with lights and colors. I am sure this will help create a lot of new and fun little components, hope you can keep the community tracker up to date

    • @andfanilo
      @andfanilo  2 роки тому +1

      That would be so cool! You should definitely try this one when you have time
      TBH I think I've missed some component announcements on the forum so I'm not sure if the tracker has all of the contributions :( ... I'm currently building a new uni course + building UA-cam videos, so I'm not really present right now anywhere else, I hope to be back soon!

    • @jeffaw5546
      @jeffaw5546 3 місяці тому

      Amazing work bro! If anyone wants to extend streamlit functionality this is 100% the video to go to🎉

  • @louis_korczowski
    @louis_korczowski 2 роки тому

    Excellent !

    • @andfanilo
      @andfanilo  2 роки тому

      Merci pour le soutien :) I'll be waiting for your Streamlit component now!

  • @letoand5004
    @letoand5004 17 днів тому

    Thanks for the video. So is it possible to make a process animation (graph with dots moving between nodes) with javascript and then integrate it to streamlit api?

    • @andfanilo
      @andfanilo  15 днів тому

      Like this silly demo I did a long time ago: github.com/andfanilo/streamlit-d3-demo ?
      Yes you could! As long as you find the adequate JS component to embed into a Streamlit component, it should be doable :)

  • @PalashBaderia
    @PalashBaderia 8 місяців тому

    Hey, your video seems really good but you have not showed the component rendering with the build file, I am trying but it is showing me component error even though the same component is working when I try to do the embedding with port (I am trying to embed react app into streamlit), if possible could you please give explanation for this would be helpful, thanks :)

  • @wallacypasqualini7661
    @wallacypasqualini7661 9 місяців тому

    Hello! Regarding the problem with requirements.txt, have you seen the Python Dependencies Manager options? There are good options. My favorite is Poetry because it's similar to the way node.js manages dependencies in JavaScript.

    • @andfanilo
      @andfanilo  9 місяців тому +1

      I've yet to try Poetry but I've always heard good things about it :)
      Hatch is another one I'm looking to try. Well I'm putting this as a video idea for when I'm bored of doing Streamlit videos!
      Thanks for sharing

  • @ahmedlingo6556
    @ahmedlingo6556 2 роки тому

    AMAZING

    • @andfanilo
      @andfanilo  2 роки тому

      Thanks for the support 😁 looking forward to seeing your Streamlit component, which one would you build?

  • @afizs
    @afizs 2 роки тому

    Great one Fanilo!

    • @andfanilo
      @andfanilo  2 роки тому +1

      Thanks for the support Afiz :) will be waiting for your Streamlit component

  • @louis_korczowski
    @louis_korczowski 2 роки тому

    08:27 actually you can store automatically the python requirements using `pip freeze > requirements.txt` ^^

    • @andfanilo
      @andfanilo  2 роки тому +1

      Eheh thanks for pointing this out! Yep you could (I actually am a fan of pip-tools github.com/jazzband/pip-tools to manage requirements from a draft file), but I'm sad there's no easy Python way to add/remove a package from the requirements.txt file and the virtual environment with a single command, I don't think poetry does it :/

  • @SHEKHARKHADKA-vb1zg
    @SHEKHARKHADKA-vb1zg 6 місяців тому

    Hi Fanilo Andrianasolo, I'm really struggling to containerize this node js and streamlit together in docker container, do you have any docker template for this?

    • @andfanilo
      @andfanilo  6 місяців тому

      Hey! Have you read this one: docs.streamlit.io/deploy/tutorials/docker ? Can provide a good starting block

    • @SHEKHARKHADKA-vb1zg
      @SHEKHARKHADKA-vb1zg 6 місяців тому

      @@andfanilo hi Fanilo, yes I did, this docs is only for the docker build with streamlit only, but my application contains the streamlit +streamlit component API i.e. react which need npm install and npm run start.
      Do you have any docker build template/docs for this, I'm really really struggling here for last couple of weeks?

  • @balachandar6945
    @balachandar6945 10 місяців тому

    How to deploy this app in snowflake? Is it possible to?

    • @andfanilo
      @andfanilo  10 місяців тому

      It is possible but I've personally never tried as I'm not using Snowflake. You should ask this question on the forum discuss.streamlit.io/ :)

  • @wgalloPT
    @wgalloPT 2 роки тому

    Question: hi Fanilo...what would you do to accomplish "mousedown event" with streamlit?

    • @andfanilo
      @andfanilo  Рік тому

      Hey!
      What do you mean? You want to send back an event to Python from a JS mouseevent down event? You can attach the event `object.addEventListener("mousedown", callback);` on any div.
      But you'll be sending way too much events back to Python this way, you'll need to make sure you debounce the event so it is not sent too many times www.freecodecamp.org/news/debounce-and-throttle-in-react-with-hooks/
      Yeah JS can be a bit of a new world..

    • @wgalloPT
      @wgalloPT Рік тому

      something like that..
      def mousePoints(event, x, y, flags, params):
      if event == cv2.EVENT_LBUTTONDOWN:
      size = len(pointsList)
      if size != 0 and size % 3 != 0:
      cv2.line(img, tuple(pointsList[round((size - 1) / 3) * 3]), (x, y)@@andfanilo

    • @andfanilo
      @andfanilo  Рік тому

      Ah but that looks like an OpenCV event, not a javascript one, so it’s a different story 🤔 sorry I’ve never tried OpenCV in Streamlit, your code looks fine though, what kind of error is it throwing?

    • @wgalloPT
      @wgalloPT Рік тому

      @@andfanilo actually I am trying to get that opencv code to work with streamlit. So far I havent being able to and I wonder if its because of the mouse down...thank you so much for replying fanilo..

    • @wgalloPT
      @wgalloPT Рік тому

      if you dont mind im going to email the code. All I need from you is to tell me if I can accomplish it or not in streamlit. It would greatly help me !!!

  • @VictorDlocalhost
    @VictorDlocalhost Рік тому

    Excellent solution, but I would like to perform the same in pie chart

    • @andfanilo
      @andfanilo  Рік тому

      Hey Victor! A Pie Chart from which JS library would you like to integrate?

    • @VictorDlocalhost
      @VictorDlocalhost Рік тому

      @@andfanilo Plotly

    • @andfanilo
      @andfanilo  Рік тому

      I haven't tried but replacing `type: 'bar'` with `type: 'pie'` in the input specification should do the trick
      You should be able to use github.com/null-jones/streamlit-plotly-events for this btw

    • @VictorDlocalhost
      @VictorDlocalhost Рік тому

      @@andfanilo Yes, I decide to use the second alternative. Thank you.

  • @darkcss1054
    @darkcss1054 Рік тому

    From your understanding, would it be possible to get React to return attributes from a column that is clicked on a Pydeck chart loaded in Streamlit through components.html? Currently the Pydeck component of Streamlit has performance issues so using it through components.html is a must.

    • @andfanilo
      @andfanilo  Рік тому +1

      components.html doesn't return results back to Streamlit 😞 so you'd need to either build your own component like in this tutorial or implement using discuss.streamlit.io/t/code-snippet-create-components-without-any-frontend-tooling-no-react-babel-webpack-etc/13064 for the vanilla version
      I think streamlit pydeck widget does some conversions under the hood that could slow it down, so if you need only a very specific subset of pydeck capabilities, sure you can rebuild it yourself so it's lighter than the native widget like in this tutorial 👌 didn't try it myself though so don't know how optimized you can get it to be

    • @darkcss1054
      @darkcss1054 Рік тому

      @@andfanilo I'm stuck at 5:22. What would be the deck gl (the javascript the pydeck package is wrapped around) equivalent of Plotly newPlot?

    • @andfanilo
      @andfanilo  Рік тому

      deck.gl/docs/get-started/using-standalone
      new Deck? (Not tested 😇 currently enjoying a little holiday 🕶️)

    • @darkcss1054
      @darkcss1054 Рік тому

      @@andfanilo I'm getting "Uncaught ReferenceError: Deck is not defined". Feels bad to be a total newb on javascript 😓

    • @andfanilo
      @andfanilo  Рік тому +1

      @@darkcss1054 ouch! even with the import line `import {Deck} from '@deck.gl/core` at the start of the script and the `npm install @deck.gl/core @deck.gl/layers` ?
      Sorry I can't try right now but I do hope you manage to make it :o

  • @jackychan4640
    @jackychan4640 Рік тому

    Hey. I am doing the openai with streamlit. I have problem with the secrets.toml file. Hope you can help

    • @andfanilo
      @andfanilo  Рік тому +1

      Hey Jacky! I'm in holidays so I'm not 100% into Streamlit right now :)
      Though...what is happening? Did you put your secrets.toml file in .streamlit folder at the root of your project, then using st.secrets? Is your toml file correctly formatted?
      While I'm in holidays, you may have better luck on discuss.streamlit.io/
      Also I think @Avra_b has a video about it on ua-cam.com/video/BHwVRI9N8B0/v-deo.html, if you follow what it does it may help you
      Have a nice day!

    • @jackychan4640
      @jackychan4640 Рік тому

      @@andfanilo thanks a lot. Sorry for the interrupt your holiday. Wishing you happy holidays and Happy New Year 2023

  • @andrewlu8432
    @andrewlu8432 Рік тому

    the speed so fast, I can't understand it!

    • @andfanilo
      @andfanilo  Рік тому

      This is meant to be an overview of the implementation process, for a slow tutorial you'd be reading a blog tutorial like streamlit-components-tutorial.netlify.app/
      Have a nice day!

  • @johngoad
    @johngoad Рік тому

    "The truth is Python is only a front end for javascript"

    • @andfanilo
      @andfanilo  Рік тому

      Lol I forgot I said that 😂 too many reading source code from Streamlit, Dash and Ipywidgets !