Thoughts about the "interactive mode" #71
Closed
falkoschindler
started this conversation in
Ideas / Feature Requests
Replies: 1 comment
-
I started working on a branch that removes the interactive mode: This solves all the questions about the name, the warning and PyTest detection. Needs a bit more testing. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When NiceGUI doesn't find a
ui.run()
, it runs in a so-called "interactive mode". Originally it was introduced to be able to use NiceGUI interactively in Python shells likepython
oripython
.Although it is of little use to interactively build UIs, it might be useful to allow importing modules that depend on NiceGUI. E.g. suppose you have written a prime number checker
my_prime
that comes with a functionis_prime(n)
and a tiny UI factory methodshow_sieve_of_eratosthenes()
. Thanks to the interactive mode you can startpython
, importmy_prime
and fiddle around with the functionis_prime(n)
. NiceGUI is fine with not findingui.run()
and simply doesn't start a server.The other important use case are PyTests: We might need to import modules that depend on NiceGUI, but there is no
ui.run()
and thus no server needs to start.So the purpose of this mode is actually quite clear. But the following questions remain:
ui.run()
is forbidden in interactive mode ("Error: Unexpected ui.run() in interactive mode.").Beta Was this translation helpful? Give feedback.
All reactions