@@ -360,6 +360,109 @@ <h2 style="border-left: 4px solid var(--primary-color); padding-left: 1.5rem; ma
360360 </ div >
361361 </ section >
362362
363+ <!-- Resetting to Defaults -->
364+ < section style ="margin-bottom: 4rem; ">
365+ < h2 style ="border-left: 4px solid var(--primary-color); padding-left: 1.5rem; margin-bottom: 2rem; ">
366+ Resetting to Default Values
367+ </ h2 >
368+
369+ < p style ="font-size: 1.1rem; margin-bottom: 2rem; ">
370+ The < code > restore_defaults()</ code > method clears all remembered values, returning widgets to their original defaults.
371+ </ p >
372+
373+ < div style ="background: #fff3cd; border-left: 4px solid #ffc107; padding: 1.5rem; margin-bottom: 2rem; border-radius: var(--border-radius); ">
374+ < h3 style ="color: #856404; margin-top: 0; "> ⚠️ Important: Re-execution Required</ h3 >
375+ < p style ="color: #856404; margin: 0; ">
376+ < strong > In Jupyter:</ strong > You must re-run the cell containing your widgets after calling < code > restore_defaults()</ code > .< br >
377+ < strong > In Terminal:</ strong > You must re-run your script after calling < code > restore_defaults()</ code > .
378+ </ p >
379+ < p style ="color: #856404; margin-top: 1rem; margin-bottom: 0; ">
380+ The method removes the memory file (< code > ~/.ezinput/{title}.yml</ code > ), but the widgets won't visually change until you re-execute the code that creates them.
381+ </ p >
382+ </ div >
383+
384+ < h3 > Basic Usage</ h3 >
385+ < div class ="code-block ">
386+ < pre > < code class ="language-python "> from ezinput import EZInput
387+
388+ gui = EZInput("my_analysis")
389+
390+ # Add widgets with remember_value=True parameter
391+ threshold = gui.add_float_range("thresh", "Threshold:", 0, 1,
392+ default=0.5, remember_value=True)
393+ method = gui.add_dropdown("method", ["A", "B", "C"], "Method:",
394+ default="A", remember_value=True)
395+
396+ gui.show()
397+
398+ # After user runs multiple times with different values...
399+ # Clear all remembered values
400+ gui.restore_defaults()
401+
402+ print("✓ Remembered values cleared!")
403+ print("🔄 Re-run this cell/script to see default values restored.")</ code > </ pre >
404+ </ div >
405+
406+ < h3 style ="margin-top: 2.5rem; "> Workflow Example (Jupyter)</ h3 >
407+ < div class ="code-block ">
408+ < pre > < code class ="language-python "> # Cell 1: Initial setup with remembered values
409+ from ezinput import EZInput
410+
411+ gui = EZInput("experiment")
412+ threshold = gui.add_float_range("thresh", "Threshold:", 0, 1,
413+ default=0.5, remember_value=True)
414+ gui.show()
415+
416+ # User sets threshold=0.8, runs analysis multiple times...
417+ # threshold.value is now remembered as 0.8
418+
419+ # Cell 2: Reset to defaults
420+ gui.restore_defaults() # Deletes ~/.ezinput/experiment.yml
421+
422+ # Cell 3: Re-run Cell 1 to see defaults
423+ # NOW when you re-run Cell 1, threshold will default to 0.5 again!</ code > </ pre >
424+ </ div >
425+
426+ < h3 style ="margin-top: 2.5rem; "> Workflow Example (Terminal Script)</ h3 >
427+ < div class ="code-block ">
428+ < pre > < code class ="language-python "> # analyze.py
429+ from ezinput import EZInput
430+ import sys
431+
432+ if len(sys.argv) > 1 and sys.argv[1] == "--reset":
433+ # User ran: python analyze.py --reset
434+ gui = EZInput("analysis")
435+ gui.restore_defaults()
436+ print("✓ Defaults restored!")
437+ print("🔄 Run 'python analyze.py' again to use default values.")
438+ sys.exit(0)
439+
440+ # Normal execution
441+ gui = EZInput("analysis")
442+ threshold = gui.add_float_range("thresh", "Threshold:", 0, 1,
443+ default=0.5, remember_value=True)
444+ gui.show()
445+
446+ # Run analysis with threshold.value...
447+
448+ # Usage:
449+ # python analyze.py # Normal run (uses remembered values)
450+ # python analyze.py --reset # Clear remembered values
451+ # python analyze.py # Next run uses defaults again</ code > </ pre >
452+ </ div >
453+
454+ < div class ="feature-highlight " style ="margin-top: 2rem; ">
455+ < h3 > 💡 When to Use restore_defaults()</ h3 >
456+ < ul style ="line-height: 1.8; ">
457+ < li > Starting a fresh experiment with clean parameters</ li >
458+ < li > Testing your GUI with original default values</ li >
459+ < li > Removing accumulated remembered values from development</ li >
460+ < li > Providing a "reset" option in your scripts</ li >
461+ < li > Debugging when values seem stuck at unexpected defaults</ li >
462+ </ ul >
463+ </ div >
464+ </ section >
465+
363466 <!-- Best Practices -->
364467 < section style ="margin-bottom: 4rem; ">
365468 < h2 style ="border-left: 4px solid var(--primary-color); padding-left: 1.5rem; margin-bottom: 2rem; ">
0 commit comments