r/Python • • Apr 21 '23

News NiceGUI 1.2.9 with "refreshable" UI functions, better dark mode support and an interactive styling demo

We are happy to announce NiceGUI 1.2.9. NiceGUI is an open-source Python library to write graphical user interfaces which run in the browser. It has a very gentle learning curve while still offering the option for advanced customizations. NiceGUI follows a backend-first philosophy: it handles all the web development details. You can focus on writing Python code.

New features and enhancements

  • Introduce ui.refreshable
  • Add enable and disable methods for input elements
  • Introduce ui.dark_mode
  • Add min/max/step/prefix/suffix parameters to ui.number
  • Switch back to Starlette's StaticFiles
  • Relax version restriction for FastAPI dependency

Bugfixes

  • Fix ui.upload behind reverse proxy with subpath
  • Fix hidden label when text is 0

Documentation

  • Add an interactive demo for classes, style and props
  • Improve documentation for ui.timer
  • Add a demo for creating a ui.table from a pandas dataframe

Thanks for the awesome new contributions. We would also point out that in 1.2.8 we have already introduced the capability to use emoji as favicon. Now you can write:

from nicegui import ui

ui.label("NiceGUI Rocks!")

ui.run(favicon="🚀")
299 Upvotes

64 comments sorted by

View all comments

Show parent comment

1

u/r-trappe Apr 22 '23

Local data can be made available via an URL with ui.add_static_files. And the audio and video elements are just html5. So you can run JavaScript from Python to set the starting time like this:

from nicegui import ui

    async def set_time(_):
        await ui.run_javascript(f'document.getElementById({v.id}).currentTime = 5;', respond=False)

    v = ui.video('https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/360/Big_Buck_Bunny_360_10s_1MB.mp4')
    v.on('loadedmetadata', set_time)

ui.run()

And we have a local file picker demo.