Skip to content

topbar -> button & ButtonWidget || Added disabled feature & font size & right-click action & toggle select#458

Open
JimChr-R4GN4R wants to merge 19 commits intolouisnw01:mainfrom
JimChr-R4GN4R:main
Open

topbar -> button & ButtonWidget || Added disabled feature & font size & right-click action & toggle select#458
JimChr-R4GN4R wants to merge 19 commits intolouisnw01:mainfrom
JimChr-R4GN4R:main

Conversation

@JimChr-R4GN4R
Copy link

@JimChr-R4GN4R JimChr-R4GN4R commented Sep 27, 2024

def do_something(chart):
    # Enable-Disable button feature
    myButton = chart.topbar['myButton']
    myButton.disable()
    ...
    <task code>
    ...    
    my_button.enable()
    
    # Set toggle select feature
    if myButton.is_toggle_selected:
        myButton.toggle_deselect()
    else:
        myButton.toggle_select()

# Right-Click function feature
def do_something_else(chart):
    myButton = chart.topbar['myButton']
    myButton.disable()
    ...
    update_button.enable()


topbar.button("myButton", "Click Me", disabled=False, font_size='25px', func=do_something, right_click_func=lambda event: on_right_click(chart), selected_bg="#ffffff")

When button is disabled, if you press it (left or right click), it does not call the do_something function and it's text get's opacity=0.5

ATTENTION: best practice for the right_click_func feature is to set the function like this right_click_func=lambda event: do_something_else(chart) instead of just right_click_func=do_something_else, because if you need to use the chart variable, the function will through error.

If you don't set selected_bg, the toggle select feature will be disabled.

@JimChr-R4GN4R JimChr-R4GN4R changed the title topbar -> button & ButtonWidget || Added disabled feature topbar -> button & ButtonWidget || Added disabled feature and font size Sep 27, 2024
@JimChr-R4GN4R JimChr-R4GN4R changed the title topbar -> button & ButtonWidget || Added disabled feature and font size topbar -> button & ButtonWidget || Added disabled feature & font size & right-click action Sep 27, 2024
@JimChr-R4GN4R JimChr-R4GN4R changed the title topbar -> button & ButtonWidget || Added disabled feature & font size & right-click action topbar -> button & ButtonWidget || Added disabled feature & font size & right-click action & toggle select Sep 28, 2024
Same functionality with hide_data and show_data, but if the data is visible, it will be hidden, and vice versa without the need of adding ifs and variables in your code.
If you create a variable of marker_list(), you may do
markers = chart.marker_list(m_list)
chart.remove_markers(markers)
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.

1 participant