Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New macro @bindname to display variable name before bond #305

Merged
merged 1 commit into from
Aug 25, 2024
Merged

Conversation

fonsp
Copy link
Member

@fonsp fonsp commented Aug 20, 2024

This PR makes a macro @bindname available when you do using PlutoUI. It's like @bind, but it will also show the name of the bound variable before the widget (height = ).

image

This solves a common pattern: writing the variable name by hand in markdown, and then interpolating the @bind call. See e.g. https://discourse.julialang.org/t/current-maintained-interactive-julia-gui-system-mid-2024/118318/11?u=fonsp

Details

The styling matches exactly that of a variable declaration.

This will also still work in a standalone file without Pluto:

image Scherm­afbeelding 2024-08-25 om 09 55 54

Copy link

Try this Pull Request!

Open Julia and type:

julia> import Pkg
julia> Pkg.activate(temp=true)
julia> Pkg.add(url="https://github.com/JuliaPluto/PlutoUI.jl", rev="@bindname")
julia> using PlutoUI

Or run this code in your browser: Run with binder

@fonsp fonsp merged commit daed4df into main Aug 25, 2024
4 checks passed
@fonsp fonsp deleted the @bindname branch August 25, 2024 07:56
@roflmaostc
Copy link

Any plan to change the default to show_value=true. Showing especially the variable name without value is never something I wanted, only the other way.

@fonsp
Copy link
Member Author

fonsp commented Oct 2, 2024

Hey @roflmaostc !

Yes that is the plan! But a bit tricky to change the default, I am afraid to break things...

@roflmaostc
Copy link

It would break a bit of layout, you mean?

As a user it would display two numbers instead of one. So at least it would not disappear (if the default would be true)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants